Video4Linux
Single-page view · as markdown
Application Priority
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
When multiple applications share a device it may be desirable to assign them different priorities. Contrary to the traditional "rm -rf /" school of thought, a video recording application could for example block other applications from changing video controls or switching the current TV channel. Another objective is to permit low priority applications working in background, which can be preempted by user controlled applications and automatically regain control of the device at a later time.
Since these features cannot be implemented entirely in user space V4L2 defines the VIDIOC_G_PRIORITY and VIDIOC_S_PRIORITY ioctls to request and query the access priority associate with a file descriptor. Opening a device assigns a medium priority, compatible with earlier versions of V4L2 and drivers not supporting these ioctls. Applications requiring a different priority will usually call VIDIOC_S_PRIORITY after verifying the device with the ioctl VIDIOC_QUERYCAP ioctl.
Ioctls changing driver properties, such as VIDIOC_S_INPUT, return an EBUSY error code after another application obtained higher priority.
Audio Inputs and Outputs
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Audio inputs and outputs are physical connectors of a device. Video capture devices have inputs, output devices have outputs, zero or more each. Radio devices have no audio inputs or outputs. They have exactly one tuner which in fact is an audio source, but this API associates tuners with video inputs or outputs only, and radio devices have none of these. 1 A connector on a TV card to loop back the received audio signal to a sound card is not considered an audio output.
Audio and video inputs and outputs are associated. Selecting a video source also selects an audio source. This is most evident when the video and audio source is a tuner. Further audio connectors can combine with more than one video input or output. Assumed two composite video inputs and two audio inputs exist, there may be up to four valid combinations. The relation of video and audio connectors is defined in the audioset field of the respective struct v4l2_input or struct v4l2_output, where each bit represents the index number, starting at zero, of one audio input or output.
To learn about the number and attributes of the available inputs and outputs applications can enumerate them with the ioctl VIDIOC_ENUMAUDIO and VIDIOC_ENUMAUDOUT ioctl, respectively. The struct v4l2_audio returned by the ioctl VIDIOC_ENUMAUDIO ioctl also contains signal status information applicable when the current audio input is queried.
The VIDIOC_G_AUDIO and VIDIOC_G_AUDOUT ioctls report the current audio input and output, respectively.
To select an audio input and change its properties applications call the VIDIOC_S_AUDIO ioctl. To select an audio output (which presently has no changeable properties) applications call the VIDIOC_S_AUDOUT ioctl.
Drivers must implement all audio input ioctls when the device has multiple selectable audio inputs, all audio output ioctls when the device has multiple selectable audio outputs. When the device has any audio inputs or outputs the driver must set the V4L2_CAP_AUDIO flag in the struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl.
Example: Information about the current audio input #
struct v4l2_audio audio;
;
if
;
Example: Switching to the first audio input #
struct v4l2_audio audio;
; /* clear audio.mode, audio.reserved */
audio.index = 0;
if
[1] Actually struct v4l2_audio ought to have a tuner field like struct v4l2_input, not only making the API more consistent but also permitting radio devices with multiple tuners.
References
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
CEA 608-E #
title: CEA-608-E R-2014 "Line 21 Data Services"
author: Consumer Electronics Association (http://www.ce.org)
EN 300 294 #
title: EN 300 294 "625-line television Wide Screen Signalling (WSS)"
author: European Telecommunication Standards Institute (http://www.etsi.org)
ETS 300 231 #
title: ETS 300 231 "Specification of the domestic video Programme Delivery Control system (PDC)"
author: European Telecommunication Standards Institute (http://www.etsi.org)
ETS 300 706 #
title: ETS 300 706 "Enhanced Teletext specification"
author: European Telecommunication Standards Institute (http://www.etsi.org)
ISO 13818-1 #
title: ITU-T Rec. H.222.0 | ISO/IEC 13818-1 "Information technology --- Generic coding of moving pictures and associated audio information: Systems"
author: International Telecommunication Union (http://www.itu.ch), International Organisation for Standardisation (http://www.iso.ch)
ISO 13818-2 #
title: ITU-T Rec. H.262 | ISO/IEC 13818-2 "Information technology --- Generic coding of moving pictures and associated audio information: Video"
author: International Telecommunication Union (http://www.itu.ch), International Organisation for Standardisation (http://www.iso.ch)
ITU BT.470 #
title: ITU-R Recommendation BT.470-6 "Conventional Television Systems"
author: International Telecommunication Union (http://www.itu.ch)
ITU BT.601 #
title: ITU-R Recommendation BT.601-5 "Studio Encoding Parameters of Digital Television for Standard 4:3 and Wide-Screen 16:9 Aspect Ratios"
author: International Telecommunication Union (http://www.itu.ch)
ITU BT.653 #
title: ITU-R Recommendation BT.653-3 "Teletext systems"
author: International Telecommunication Union (http://www.itu.ch)
ITU BT.709 #
title: ITU-R Recommendation BT.709-5 "Parameter values for the HDTV standards for production and international programme exchange"
author: International Telecommunication Union (http://www.itu.ch)
ITU BT.1119 #
title: ITU-R Recommendation BT.1119 "625-line television Wide Screen Signalling (WSS)"
author: International Telecommunication Union (http://www.itu.ch)
ITU-T Rec. H.264 Specification (04/2017 Edition) #
title: ITU-T Recommendation H.264 "Advanced Video Coding for Generic Audiovisual Services"
author: International Telecommunication Union (http://www.itu.ch)
ITU H.265/HEVC #
title: ITU-T Rec. H.265 | ISO/IEC 23008-2 "High Efficiency Video Coding"
author: International Telecommunication Union (http://www.itu.ch), International Organisation for Standardisation (http://www.iso.ch)
JFIF #
title: JPEG File Interchange Format
subtitle: Version 1.02
author: Independent JPEG Group (http://www.ijg.org)
ITU-T.81 #
title: ITU-T Recommendation T.81 "Information Technology --- Digital Compression and Coding of Continuous-Tone Still Images --- Requirements and Guidelines"
author: International Telecommunication Union (http://www.itu.int)
W3C JPEG JFIF #
title: JPEG JFIF
author: The World Wide Web Consortium (http://www.w3.org)
SMPTE 12M #
title: SMPTE 12M-1999 "Television, Audio and Film - Time and Control Code"
author: Society of Motion Picture and Television Engineers (http://www.smpte.org)
SMPTE 170M #
title: SMPTE 170M-1999 "Television - Composite Analog Video Signal - NTSC for Studio Applications"
author: Society of Motion Picture and Television Engineers (http://www.smpte.org)
SMPTE 240M #
title: SMPTE 240M-1999 "Television - Signal Parameters - 1125-Line High-Definition Production"
author: Society of Motion Picture and Television Engineers (http://www.smpte.org)
SMPTE RP 431-2 #
title: SMPTE RP 431-2:2011 "D-Cinema Quality - Reference Projector and Environment"
author: Society of Motion Picture and Television Engineers (http://www.smpte.org)
SMPTE ST 2084 #
title: SMPTE ST 2084:2014 "High Dynamic Range Electro-Optical Transfer Function of Master Reference Displays"
author: Society of Motion Picture and Television Engineers (http://www.smpte.org)
sRGB #
title: IEC 61966-2-1 ed1.0 "Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB"
author: International Electrotechnical Commission (http://www.iec.ch)
sYCC #
title: IEC 61966-2-1-am1 ed1.0 "Amendment 1 - Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB"
author: International Electrotechnical Commission (http://www.iec.ch)
xvYCC #
title: IEC 61966-2-4 ed1.0 "Multimedia systems and equipment - Colour measurement and management - Part 2-4: Colour management - Extended-gamut YCC colour space for video applications - xvYCC"
author: International Electrotechnical Commission (http://www.iec.ch)
opRGB #
title: IEC 61966-2-5 "Multimedia systems and equipment - Colour measurement and management - Part 2-5: Colour management - Optional RGB colour space - opRGB"
author: International Electrotechnical Commission (http://www.iec.ch)
ITU BT.2020 #
title: ITU-R Recommendation BT.2020 (08/2012) "Parameter values for ultra-high definition television systems for production and international programme exchange"
author: International Telecommunication Union (http://www.itu.ch)
EBU Tech 3213 #
title: E.B.U. Standard for Chromaticity Tolerances for Studio Monitors
author: European Broadcast Union (http://www.ebu.ch)
EBU Tech 3321 #
title: E.B.U. guidelines for Consumer Flat Panel Displays (FPDs)
author: European Broadcast Union (http://www.ebu.ch)
IEC 62106 #
title: Specification of the radio data system (RDS) for VHF/FM sound broadcasting in the frequency range from 87,5 to 108,0 MHz
author: International Electrotechnical Commission (http://www.iec.ch)
NRSC-4-B #
title: NRSC-4-B: United States RBDS Standard
author: National Radio Systems Committee (http://www.nrscstandards.org)
ISO 12232:2006 #
title: Photography --- Digital still cameras --- Determination of exposure index, ISO speed ratings, standard output sensitivity, and recommended exposure index
author: International Organization for Standardization (http://www.iso.org)
CEA-861-E #
title: A DTV Profile for Uncompressed High Speed Digital Interfaces
author: Consumer Electronics Association (http://www.ce.org)
VESA DMT #
title: VESA and Industry Standards and Guidelines for Computer Display Monitor Timing (DMT)
author: Video Electronics Standards Association (http://www.vesa.org)
E-DDC #
title: VESA Enhanced Display Data Channel (E-DDC) Standard
subtitle: Version 1.3
author: Video Electronics Standards Association (http://www.vesa.org)
EDID #
title: VESA Enhanced Extended Display Identification Data Standard
subtitle: Release A, Revision 2
author: Video Electronics Standards Association (http://www.vesa.org)
HDCP #
title: High-bandwidth Digital Content Protection System
subtitle: Revision 1.3
author: Digital Content Protection LLC (http://www.digital-cp.com)
HDMI #
title: High-Definition Multimedia Interface
subtitle: Specification Version 1.4a
author: HDMI Licensing LLC (http://www.hdmi.org)
HDMI2 #
title: High-Definition Multimedia Interface
subtitle: Specification Version 2.0
author: HDMI Licensing LLC (http://www.hdmi.org)
DP #
title: VESA DisplayPort Standard
subtitle: Version 1, Revision 2
author: Video Electronics Standards Association (http://www.vesa.org)
poynton #
title: Digital Video and HDTV, Algorithms and Interfaces
author: Charles Poynton
colimg #
title: Color Imaging: Fundamentals and Applications
author: Erik Reinhard et al.
VP8 #
title: RFC 6386: "VP8 Data Format and Decoding Guide"
author: - J. Bankoski et al.
VP9 #
title: VP9 Bitstream & Decoding Process Specification
author: Adrian Grange (Google), Peter de Rivaz (Argon Design), Jonathan Hunt (Argon Design)
AV1 #
title: AV1 Bitstream & Decoding Process Specification
author: Peter de Rivaz, Argon Design Ltd, Jack Haughton, Argon Design Ltd
Buffers
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
A buffer contains data exchanged by application and driver using one of the Streaming I/O methods. In the multi-planar API, the data is held in planes, while the buffer structure acts as a container for the planes. Only pointers to buffers (planes) are exchanged, the data itself is not copied. These pointers, together with meta-information like timestamps or field parity, are stored in a struct v4l2_buffer, argument to the vidioc_querybuf, VIDIOC_QBUF and VIDIOC_DQBUF ioctl. In the multi-planar API, some plane-specific members of struct v4l2_buffer, such as pointers and sizes for each plane, are stored in struct v4l2_plane instead. In that case, struct v4l2_buffer contains an array of plane structures.
Dequeued video buffers come with timestamps. The driver decides at which part of the frame and with which clock the timestamp is taken. Please see flags in the masks V4L2_BUF_FLAG_TIMESTAMP_MASK and V4L2_BUF_FLAG_TSTAMP_SRC_MASK in Buffer Flags. These flags are always valid and constant across all buffers during the whole video stream. Changes in these flags may take place as a side effect of VIDIOC_S_INPUT or VIDIOC_S_OUTPUT however. The V4L2_BUF_FLAG_TIMESTAMP_COPY timestamp type which is used by e.g. on mem-to-mem devices is an exception to the rule: the timestamp source flags are copied from the OUTPUT video buffer to the CAPTURE video buffer.
Interactions between formats, controls and buffers #
V4L2 exposes parameters that influence the buffer size, or the way data is laid out in the buffer. Those parameters are exposed through both formats and controls. One example of such a control is the V4L2_CID_ROTATE control that modifies the direction in which pixels are stored in the buffer, as well as the buffer size when the selected format includes padding at the end of lines.
The set of information needed to interpret the content of a buffer (e.g. the pixel format, the line stride, the tiling orientation or the rotation) is collectively referred to in the rest of this section as the buffer layout.
Controls that can modify the buffer layout shall set the V4L2_CTRL_FLAG_MODIFY_LAYOUT flag.
Modifying formats or controls that influence the buffer size or layout require the stream to be stopped. Any attempt at such a modification while the stream is active shall cause the ioctl setting the format or the control to return the EBUSY error code. In that case drivers shall also set the V4L2_CTRL_FLAG_GRABBED flag when calling VIDIOC_QUERYCTRL() or VIDIOC_QUERY_EXT_CTRL() for such a control while the stream is active.
Controls that only influence the buffer layout can be modified at any time when the stream is stopped. As they don't influence the buffer size, no special handling is needed to synchronize those controls with buffer allocation and the V4L2_CTRL_FLAG_GRABBED flag is cleared once the stream is stopped.
Formats and controls that influence the buffer size interact with buffer allocation. The simplest way to handle this is for drivers to always require buffers to be reallocated in order to change those formats or controls. In that case, to perform such changes, userspace applications shall first stop the video stream with the VIDIOC_STREAMOFF() ioctl if it is running and free all buffers with the VIDIOC_REQBUFS() ioctl if they are allocated. After freeing all buffers the V4L2_CTRL_FLAG_GRABBED flag for controls is cleared. The format or controls can then be modified, and buffers shall then be reallocated and the stream restarted. A typical ioctl sequence is
VIDIOC_STREAMOFF
VIDIOC_REQBUFS(0)
VIDIOC_S_EXT_CTRLS
VIDIOC_S_FMT
VIDIOC_REQBUFS(n)
VIDIOC_QBUF
VIDIOC_STREAMON
The second VIDIOC_REQBUFS() call will take the new format and control value into account to compute the buffer size to allocate. Applications can also retrieve the size by calling the VIDIOC_G_FMT() ioctl if needed.
When reallocation is required, any attempt to modify format or controls that influences the buffer size while buffers are allocated shall cause the format or control set ioctl to return the EBUSY error. Any attempt to queue a buffer too small for the current format or controls shall cause the VIDIOC_QBUF() ioctl to return a EINVAL error.
Buffer reallocation is an expensive operation. To avoid that cost, drivers can (and are encouraged to) allow format or controls that influence the buffer size to be changed with buffers allocated. In that case, a typical ioctl sequence to modify format and controls is
VIDIOC_STREAMOFF
VIDIOC_S_EXT_CTRLS
VIDIOC_S_FMT
VIDIOC_QBUF
VIDIOC_STREAMON
For this sequence to operate correctly, queued buffers need to be large enough for the new format or controls. Drivers shall return a ENOSPC error in response to format change (VIDIOC_S_FMT()) or control changes (VIDIOC_S_CTRL() or VIDIOC_S_EXT_CTRLS()) if buffers too small for the new format are currently queued. As a simplification, drivers are allowed to return a EBUSY error from these ioctls if any buffer is currently queued, without checking the queued buffers sizes.
Additionally, drivers shall return a EINVAL error from the VIDIOC_QBUF() ioctl if the buffer being queued is too small for the current format or controls. Together, these requirements ensure that queued buffers will always be large enough for the configured format and controls.
Userspace applications can query the buffer size required for a given format and controls by first setting the desired control values and then trying the desired format. The VIDIOC_TRY_FMT() ioctl will return the required buffer size.
VIDIOC_S_EXT_CTRLS(x)
VIDIOC_TRY_FMT()
VIDIOC_S_EXT_CTRLS(y)
VIDIOC_TRY_FMT()
The VIDIOC_CREATE_BUFS() ioctl can then be used to allocate buffers based on the queried sizes (for instance by allocating a set of buffers large enough for all the desired formats and controls, or by allocating separate set of appropriately sized buffers for each use case).
v4l2_buffer
struct v4l2_buffer #
|
__u32 |
|
Number of the buffer, set by the application except when calling VIDIOC_DQBUF, then it is set by the driver. This field can range from zero to the number of buffers allocated with the ioctl VIDIOC_REQBUFS ioctl (struct |
|
__u32 |
|
Type of the buffer, same as struct |
|
__u32 |
|
The number of bytes occupied by the data in the buffer. It depends on the negotiated data format and may change with each buffer for compressed variable size data like JPEG images. Drivers must set this field when |
|
__u32 |
|
Flags set by the application or driver, see Buffer Flags. |
|
__u32 |
|
Indicates the field order of the image in the buffer, see |
|
struct timeval |
|
For capture streams this is time when the first data byte was captured, as returned by the |
|
struct |
|
When the |
|
__u32 |
|
Set by the driver, counting the frames (not fields!) in sequence. This field is set for both input and output devices. |
|
In |
||
|
__u32 |
|
This field must be set by applications and/or drivers in accordance with the selected I/O method. See |
|
union { |
|
|
|
__u32 |
|
For the single-planar API and when |
|
unsigned long |
|
For the single-planar API and when |
|
struct v4l2_plane |
|
When using the multi-planar API, contains a userspace pointer to an array of struct |
|
int |
|
For the single-plane API and when |
|
} |
||
|
__u32 |
|
Size of the buffer (not the payload) in bytes for the single-planar API. This is set by the driver based on the calls to ioctl VIDIOC_REQBUFS and/or vidioc_create_bufs. For the multi-planar API the application sets this to the number of elements in the |
|
__u32 |
|
A place holder for future extensions. Drivers and applications must set this to 0. |
|
__u32 |
|
The file descriptor of the request to queue the buffer to. If the flag The Applications should not set If the device does not support requests, then |
v4l2_plane
struct v4l2_plane #
|
__u32 |
|
The number of bytes occupied by data in the plane (its payload). Drivers must set this field when |
|
__u32 |
|
Size in bytes of the plane (not its payload). This is set by the driver based on the calls to ioctl VIDIOC_REQBUFS and/or vidioc_create_bufs. |
|
union { |
|
|
|
__u32 |
|
When the memory type in the containing struct |
|
unsigned long |
|
When the memory type in the containing struct |
|
int |
|
When the memory type in the containing struct |
|
} |
||
|
__u32 |
|
Offset in bytes to video data in the plane. Drivers must set this field when |
|
__u32 |
|
Reserved for future use. Should be zeroed by drivers and applications. |
v4l2_buf_type
enum v4l2_buf_type #
|
|
1 |
Buffer of a single-planar video capture stream, see capture. |
|
|
9 |
Buffer of a multi-planar video capture stream, see capture. |
|
|
2 |
Buffer of a single-planar video output stream, see output. |
|
|
10 |
Buffer of a multi-planar video output stream, see output. |
|
|
3 |
Buffer for video overlay, see Video Overlay Interface. |
|
|
4 |
Buffer of a raw VBI capture stream, see raw-vbi. |
|
|
5 |
Buffer of a raw VBI output stream, see raw-vbi. |
|
|
6 |
Buffer of a sliced VBI capture stream, see Sliced VBI Data Interface. |
|
|
7 |
Buffer of a sliced VBI output stream, see Sliced VBI Data Interface. |
|
|
8 |
Buffer for video output overlay (OSD), see osd. |
|
|
11 |
Buffer for Software Defined Radio (SDR) capture stream, see sdr. |
|
|
12 |
Buffer for Software Defined Radio (SDR) output stream, see sdr. |
|
|
13 |
Buffer for metadata capture, see metadata. |
|
|
14 |
Buffer for metadata output, see metadata. |
Buffer Flags #
|
|
0x00000001 |
The buffer resides in device memory and has been mapped into the application's address space, see mmap for details. Drivers set or clear this flag when the vidioc_querybuf, vidioc_qbuf or VIDIOC_DQBUF ioctl is called. Set by the driver. |
|
|
0x00000002 |
Internally drivers maintain two buffer queues, an incoming and outgoing queue. When this flag is set, the buffer is currently on the incoming queue. It automatically moves to the outgoing queue after the buffer has been filled (capture devices) or displayed (output devices). Drivers set or clear this flag when the |
|
|
0x00000004 |
When this flag is set, the buffer is currently on the outgoing queue, ready to be dequeued from the driver. Drivers set or clear this flag when the |
|
|
0x00000040 |
When this flag is set, the buffer has been dequeued successfully, although the data might have been corrupted. This is recoverable, streaming may continue as normal and the buffer may be reused normally. Drivers set this flag when the |
|
|
0x00000080 |
This buffer is part of a request that hasn't been queued yet. |
|
|
0x00000008 |
Drivers set or clear this flag when calling the |
|
|
0x00000010 |
Similar to |
|
|
0x00000020 |
Similar to |
|
|
0x00000100 |
The |
|
|
0x00000400 |
The buffer has been prepared for I/O and can be queued by the application. Drivers set or clear this flag when the VIDIOC_QUERYBUF, VIDIOC_PREPARE_BUF, VIDIOC_QBUF or VIDIOC_DQBUF ioctl is called. |
|
|
0x00000800 |
Caches do not have to be invalidated for this buffer. Typically applications shall use this flag if the data captured in the buffer is not going to be touched by the CPU, instead the buffer will, probably, be passed on to a DMA-capable hardware unit for further processing or output. This flag is ignored unless the queue is used for memory mapping streaming I/O and reports V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability. |
|
|
0x00001000 |
Caches do not have to be cleaned for this buffer. Typically applications shall use this flag for output buffers if the data in this buffer has not been created by the CPU but by some DMA-capable unit, in which case caches have not been used. This flag is ignored unless the queue is used for memory mapping streaming I/O and reports V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability. |
|
|
0x00000200 |
Only valid if struct |
|
|
0x00100000 |
Last buffer produced by the hardware. mem2mem codec drivers set this flag on the capture queue for the last buffer when the vidioc_querybuf or VIDIOC_DQBUF ioctl is called. Due to hardware limitations, the last buffer may be empty. In this case the driver will set the |
|
|
0x00800000 |
The |
|
|
0x0000e000 |
Mask for timestamp types below. To test the timestamp type, mask out bits not belonging to timestamp type by performing a logical and operation with buffer flags and timestamp mask. |
|
|
0x00000000 |
Unknown timestamp type. This type is used by drivers before Linux 3.9 and may be either monotonic (see below) or realtime (wall clock). Monotonic clock has been favoured in embedded systems whereas most of the drivers use the realtime clock. Either kinds of timestamps are available in user space via |
|
|
0x00002000 |
The buffer timestamp has been taken from the |
|
|
0x00004000 |
The CAPTURE buffer timestamp has been taken from the corresponding OUTPUT buffer. This flag applies only to mem2mem devices. |
|
|
0x00070000 |
Mask for timestamp sources below. The timestamp source defines the point of time the timestamp is taken in relation to the frame. Logical 'and' operation between the |
|
|
0x00000000 |
End Of Frame. The buffer timestamp has been taken when the last pixel of the frame has been received or the last pixel of the frame has been transmitted. In practice, software generated timestamps will typically be read from the clock a small amount of time after the last pixel has been received or transmitten, depending on the system and other activity in it. |
|
|
0x00010000 |
Start Of Exposure. The buffer timestamp has been taken when the exposure of the frame has begun. This is only valid for the |
v4l2_memory
enum v4l2_memory #
|
|
1 |
The buffer is used for memory mapping I/O. |
|
|
2 |
The buffer is used for user pointer I/O. |
|
|
3 |
[to do] |
|
|
4 |
The buffer is used for DMA shared buffer I/O. |
Timecodes #
The v4l2_buffer_timecode structure is designed to hold a smpte12m or similar timecode. (struct timeval timestamps are stored in the struct v4l2_buffer timestamp field.)
v4l2_timecode
struct v4l2_timecode #
|
__u32 |
|
Frame rate the timecodes are based on, see Timecode Types. |
|
__u32 |
|
Timecode flags, see Timecode Flags. |
|
__u8 |
|
Frame count, 0 ... 23/24/29/49/59, depending on the type of timecode. |
|
__u8 |
|
Seconds count, 0 ... 59. This is a binary, not BCD number. |
|
__u8 |
|
Minutes count, 0 ... 59. This is a binary, not BCD number. |
|
__u8 |
|
Hours count, 0 ... 29. This is a binary, not BCD number. |
|
__u8 |
|
The "user group" bits from the timecode. |
Timecode Types #
|
|
1 |
24 frames per second, i. e. film. |
|
|
2 |
25 frames per second, i. e. PAL or SECAM video. |
|
|
3 |
30 frames per second, i. e. NTSC video. |
|
|
4 |
|
|
|
5 |
Timecode Flags #
|
|
0x0001 |
Indicates "drop frame" semantics for counting frames in 29.97 fps material. When set, frame numbers 0 and 1 at the start of each minute, except minutes 0, 10, 20, 30, 40, 50 are omitted from the count. |
|
|
0x0002 |
The "color frame" flag. |
|
|
0x000C |
Field mask for the "binary group flags". |
|
|
0x0000 |
Unspecified format. |
|
|
0x0008 |
8-bit ISO characters. |
Video Capture Example
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
file: media/v4l/capture.c
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
/*
* V4L2 video capture example
*
* This program can be used and distributed without restrictions.
*
* This program is provided with the V4L2 API
* see https://linuxtv.org/docs.php for more information
*/
;
;
static char *dev_name;
static enum io_method io = IO_METHOD_MMAP;
static int fd = -1;
struct buffer *buffers;
static unsigned int n_buffers;
static int out_buf;
static int force_format;
static int frame_count = 70;
static void
static int
static void
static int
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static void
static const char short_options = "d:hmruofc:";
static const ;
int
Defining Colorspaces in V4L2
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
In V4L2 colorspaces are defined by four values. The first is the colorspace identifier (enum v4l2_colorspace) which defines the chromaticities, the default transfer function, the default Y'CbCr encoding and the default quantization method. The second is the transfer function identifier (enum v4l2_xfer_func) to specify non-standard transfer functions. The third is the Y'CbCr encoding identifier (enum v4l2_ycbcr_encoding) to specify non-standard Y'CbCr encodings and the fourth is the quantization identifier (enum v4l2_quantization) to specify non-standard quantization methods. Most of the time only the colorspace field of struct v4l2_pix_format or struct v4l2_pix_format_mplane needs to be filled in.
On HSV formats the Hue is defined as the angle on the cylindrical color representation. Usually this angle is measured in degrees, i.e. 0-360. When we map this angle value into 8 bits, there are two basic ways to do it: Divide the angular value by 2 (0-179), or use the whole range, 0-255, dividing the angular value by 1.41. The enum v4l2_hsv_encoding specifies which encoding is used.
v4l2_colorspace
|
Identifier |
Details |
|---|---|
|
|
The default colorspace. This can be used by applications to let the driver fill in the colorspace. |
|
|
See col-smpte-170m. |
|
|
See col-rec709. |
|
|
See col-srgb. |
|
|
See col-oprgb. |
|
|
See col-bt2020. |
|
|
See col-dcip3. |
|
|
See col-smpte-240m. |
|
|
See col-sysm. |
|
|
See col-sysbg. |
|
|
See col-jpeg. |
|
|
The raw colorspace. This is used for raw image capture where the image is minimally processed and is using the internal colorspace of the device. The software that processes an image using this 'colorspace' will have to know the internals of the capture device. |
v4l2_xfer_func
|
Identifier |
Details |
|---|---|
|
|
Use the default transfer function as defined by the colorspace. |
|
|
Use the Rec. 709 transfer function. |
|
|
Use the sRGB transfer function. |
|
|
Use the opRGB transfer function. |
|
|
Use the SMPTE 240M transfer function. |
|
|
Do not use a transfer function (i.e. use linear RGB values). |
|
|
Use the DCI-P3 transfer function. |
|
|
Use the SMPTE 2084 transfer function. See xf-smpte-2084. |
v4l2_ycbcr_encoding
|
Identifier |
Details |
|---|---|
|
|
Use the default Y'CbCr encoding as defined by the colorspace. |
|
|
Use the BT.601 Y'CbCr encoding. |
|
|
Use the Rec. 709 Y'CbCr encoding. |
|
|
Use the extended gamut xvYCC BT.601 encoding. |
|
|
Use the extended gamut xvYCC Rec. 709 encoding. |
|
|
Use the default non-constant luminance BT.2020 Y'CbCr encoding. |
|
|
Use the constant luminance BT.2020 Yc'CbcCrc encoding. |
|
|
Use the SMPTE 240M Y'CbCr encoding. |
v4l2_hsv_encoding
|
Identifier |
Details |
|---|---|
|
|
For the Hue, each LSB is two degrees. |
|
|
For the Hue, the 360 degrees are mapped into 8 bits, i.e. each LSB is roughly 1.41 degrees. |
v4l2_quantization
|
Identifier |
Details |
|---|---|
|
|
Use the default quantization encoding as defined by the colorspace. This is always full range for R'G'B' and HSV. It is usually limited range for Y'CbCr. |
|
|
Use the full range quantization encoding. I.e. the range [0…1] is mapped to [0…255] (with possible clipping to [1…254] to avoid the 0x00 and 0xff values). Cb and Cr are mapped from [-0.5…0.5] to [0…255] (with possible clipping to [1…254] to avoid the 0x00 and 0xff values). |
|
|
Use the limited range quantization encoding. I.e. the range [0…1] is mapped to [16…235]. Cb and Cr are mapped from [-0.5…0.5] to [16…240]. Limited Range cannot be used with HSV. |
Detailed Colorspace Descriptions
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Detailed Colorspace Descriptions #
Colorspace SMPTE 170M (V4L2_COLORSPACE_SMPTE170M) #
The smpte170m standard defines the colorspace used by NTSC and PAL and by SDTV in general. The default transfer function is V4L2_XFER_FUNC_709. The default Y'CbCr encoding is V4L2_YCBCR_ENC_601. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.630 |
0.340 |
|
Green |
0.310 |
0.595 |
|
Blue |
0.155 |
0.070 |
|
White Reference (D65) |
0.3127 |
0.3290 |
The red, green and blue chromaticities are also often referred to as the SMPTE C set, so this colorspace is sometimes called SMPTE C as well.
The transfer function defined for SMPTE 170M is the same as the one defined in Rec. 709.
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_601 encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. This conversion to Y'CbCr is identical to the one defined in the itu601 standard and this colorspace is sometimes called BT.601 as well, even though BT.601 does not mention any color primaries.
The default quantization is limited range, but full range is possible although rarely seen.
Colorspace Rec. 709 (V4L2_COLORSPACE_REC709) #
The itu709 standard defines the colorspace used by HDTV in general. The default transfer function is V4L2_XFER_FUNC_709. The default Y'CbCr encoding is V4L2_YCBCR_ENC_709. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.640 |
0.330 |
|
Green |
0.300 |
0.600 |
|
Blue |
0.150 |
0.060 |
|
White Reference (D65) |
0.3127 |
0.3290 |
The full name of this standard is Rec. ITU-R BT.709-5.
Transfer function. Normally L is in the range [0…1], but for the extended gamut xvYCC encoding values outside that range are allowed.
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_709 encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5].
The default quantization is limited range, but full range is possible although rarely seen.
The V4L2_YCBCR_ENC_709 encoding described above is the default for this colorspace, but it can be overridden with V4L2_YCBCR_ENC_601, in which case the BT.601 Y'CbCr encoding is used.
Two additional extended gamut Y'CbCr encodings are also possible with this colorspace:
The xvYCC 709 encoding (V4L2_YCBCR_ENC_XV709, xvycc) is similar to the Rec. 709 encoding, but it allows for R', G' and B' values that are outside the range [0…1]. The resulting Y', Cb and Cr values are scaled and offset according to the limited range formula:
The xvYCC 601 encoding (V4L2_YCBCR_ENC_XV601, xvycc) is similar to the BT.601 encoding, but it allows for R', G' and B' values that are outside the range [0…1]. The resulting Y', Cb and Cr values are scaled and offset according to the limited range formula:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5] and quantized without further scaling or offsets. The non-standard xvYCC 709 or xvYCC 601 encodings can be used by selecting V4L2_YCBCR_ENC_XV709 or V4L2_YCBCR_ENC_XV601. As seen by the xvYCC formulas these encodings always use limited range quantization, there is no full range variant. The whole point of these extended gamut encodings is that values outside the limited range are still valid, although they map to R', G' and B' values outside the [0…1] range and are therefore outside the Rec. 709 colorspace gamut.
Colorspace sRGB (V4L2_COLORSPACE_SRGB) #
The srgb standard defines the colorspace used by most webcams and computer graphics. The default transfer function is V4L2_XFER_FUNC_SRGB. The default Y'CbCr encoding is V4L2_YCBCR_ENC_601. The default Y'CbCr quantization is limited range.
Note that the sycc standard specifies full range quantization, however all current capture hardware supported by the kernel convert R'G'B' to limited range Y'CbCr. So choosing full range as the default would break how applications interpret the quantization range.
The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.640 |
0.330 |
|
Green |
0.300 |
0.600 |
|
Blue |
0.150 |
0.060 |
|
White Reference (D65) |
0.3127 |
0.3290 |
These chromaticities are identical to the Rec. 709 colorspace.
Transfer function. Note that negative values for L are only used by the Y'CbCr conversion.
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_601 encoding as defined by sycc:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. This transform is identical to one defined in SMPTE 170M/BT.601. The Y'CbCr quantization is limited range.
Colorspace opRGB (V4L2_COLORSPACE_OPRGB) #
The oprgb standard defines the colorspace used by computer graphics that use the opRGB colorspace. The default transfer function is V4L2_XFER_FUNC_OPRGB. The default Y'CbCr encoding is V4L2_YCBCR_ENC_601. The default Y'CbCr quantization is limited range.
Note that the oprgb standard specifies full range quantization, however all current capture hardware supported by the kernel convert R'G'B' to limited range Y'CbCr. So choosing full range as the default would break how applications interpret the quantization range.
The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.6400 |
0.3300 |
|
Green |
0.2100 |
0.7100 |
|
Blue |
0.1500 |
0.0600 |
|
White Reference (D65) |
0.3127 |
0.3290 |
Transfer function:
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_601 encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. This transform is identical to one defined in SMPTE 170M/BT.601. The Y'CbCr quantization is limited range.
Colorspace BT.2020 (V4L2_COLORSPACE_BT2020) #
The itu2020 standard defines the colorspace used by Ultra-high definition television (UHDTV). The default transfer function is V4L2_XFER_FUNC_709. The default Y'CbCr encoding is V4L2_YCBCR_ENC_BT2020. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.708 |
0.292 |
|
Green |
0.170 |
0.797 |
|
Blue |
0.131 |
0.046 |
|
White Reference (D65) |
0.3127 |
0.3290 |
Transfer function (same as Rec. 709):
Inverse Transfer function:
Please note that while Rec. 709 is defined as the default transfer function by the itu2020 standard, in practice this colorspace is often used with the Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084). In particular Ultra HD Blu-ray discs use this combination.
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_BT2020 encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. The Y'CbCr quantization is limited range.
There is also an alternate constant luminance R'G'B' to Yc'CbcCrc (V4L2_YCBCR_ENC_BT2020_CONST_LUM) encoding:
Luma:
Yc' is clamped to the range [0…1] and Cbc and Crc are clamped to the range [-0.5…0.5]. The Yc'CbcCrc quantization is limited range.
Colorspace DCI-P3 (V4L2_COLORSPACE_DCI_P3) #
The smpte431 standard defines the colorspace used by cinema projectors that use the DCI-P3 colorspace. The default transfer function is V4L2_XFER_FUNC_DCI_P3. The default Y'CbCr encoding is V4L2_YCBCR_ENC_709. The default Y'CbCr quantization is limited range.
The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.6800 |
0.3200 |
|
Green |
0.2650 |
0.6900 |
|
Blue |
0.1500 |
0.0600 |
|
White Reference |
0.3140 |
0.3510 |
Transfer function:
Inverse Transfer function:
Y'CbCr encoding is not specified. V4L2 defaults to Rec. 709.
Colorspace SMPTE 240M (V4L2_COLORSPACE_SMPTE240M) #
The smpte240m standard was an interim standard used during the early days of HDTV (1988-1998). It has been superseded by Rec. 709. The default transfer function is V4L2_XFER_FUNC_SMPTE240M. The default Y'CbCr encoding is V4L2_YCBCR_ENC_SMPTE240M. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.630 |
0.340 |
|
Green |
0.310 |
0.595 |
|
Blue |
0.155 |
0.070 |
|
White Reference (D65) |
0.3127 |
0.3290 |
These chromaticities are identical to the SMPTE 170M colorspace.
Transfer function:
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_SMPTE240M encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. The Y'CbCr quantization is limited range.
Colorspace NTSC 1953 (V4L2_COLORSPACE_470_SYSTEM_M) #
This standard defines the colorspace used by NTSC in 1953. In practice this colorspace is obsolete and SMPTE 170M should be used instead. The default transfer function is V4L2_XFER_FUNC_709. The default Y'CbCr encoding is V4L2_YCBCR_ENC_601. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.67 |
0.33 |
|
Green |
0.21 |
0.71 |
|
Blue |
0.14 |
0.08 |
|
White Reference (C) |
0.310 |
0.316 |
The transfer function was never properly defined for NTSC 1953. The Rec. 709 transfer function is recommended in the literature:
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_601 encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is identical to one defined in SMPTE 170M/BT.601.
Colorspace EBU Tech. 3213 (V4L2_COLORSPACE_470_SYSTEM_BG) #
The tech3213 standard defines the colorspace used by PAL/SECAM in 1975. Note that this colorspace is not supported by the HDMI interface. Instead tech3321 recommends that Rec. 709 is used instead for HDMI. The default transfer function is V4L2_XFER_FUNC_709. The default Y'CbCr encoding is V4L2_YCBCR_ENC_601. The default Y'CbCr quantization is limited range. The chromaticities of the primary colors and the white reference are:
|
Color |
x |
y |
|---|---|---|
|
Red |
0.64 |
0.33 |
|
Green |
0.29 |
0.60 |
|
Blue |
0.15 |
0.06 |
|
White Reference (D65) |
0.3127 |
0.3290 |
The transfer function was never properly defined for this colorspace. The Rec. 709 transfer function is recommended in the literature:
Inverse Transfer function:
The luminance (Y') and color difference (Cb and Cr) are obtained with the following V4L2_YCBCR_ENC_601 encoding:
Y' is clamped to the range [0…1] and Cb and Cr are clamped to the range [-0.5…0.5]. The Y'CbCr quantization is limited range. This transform is identical to one defined in SMPTE 170M/BT.601.
Colorspace JPEG (V4L2_COLORSPACE_JPEG) #
This colorspace defines the colorspace used by most (Motion-)JPEG formats. The chromaticities of the primary colors and the white reference are identical to sRGB. The transfer function use is V4L2_XFER_FUNC_SRGB. The Y'CbCr encoding is V4L2_YCBCR_ENC_601 with full range quantization where Y' is scaled to [0…255] and Cb/Cr are scaled to [-128…128] and then clipped to [-128…127].
Detailed Transfer Function Descriptions #
Transfer Function SMPTE 2084 (V4L2_XFER_FUNC_SMPTE2084) #
The smpte2084 standard defines the transfer function used by High Dynamic Range content.
-
Constants:
m1 = (2610 / 4096) / 4
m2 = (2523 / 4096) * 128
c1 = 3424 / 4096
c2 = (2413 / 4096) * 32
c3 = (2392 / 4096) * 32
-
Transfer function:
L' = ((c1 + c2 * Lm1) / (1 + c3 * Lm1))m2
-
Inverse Transfer function:
L = (max(L'1/m2 - c1, 0) / (c2 - c3 * L'1/m2))1/m1
Take care when converting between this transfer function and non-HDR transfer functions: the linear RGB values [0…1] of HDR content map to a luminance range of 0 to 10000 cd/m2 whereas the linear RGB values of non-HDR (aka Standard Dynamic Range or SDR) map to a luminance range of 0 to 100 cd/m2.
To go from SDR to HDR you will have to divide L by 100 first. To go in the other direction you will have to multiply L by 100. Of course, this clamps all luminance values over 100 cd/m2 to 100 cd/m2.
There are better methods, see e.g. colimg for more in-depth information about this.
Colorspaces
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
'Color' is a very complex concept and depends on physics, chemistry and biology. Just because you have three numbers that describe the 'red', 'green' and 'blue' components of the color of a pixel does not mean that you can accurately display that color. A colorspace defines what it actually means to have an RGB value of e.g. (255, 0, 0). That is, which color should be reproduced on the screen in a perfectly calibrated environment.
In order to do that we first need to have a good definition of color, i.e. some way to uniquely and unambiguously define a color so that someone else can reproduce it. Human color vision is trichromatic since the human eye has color receptors that are sensitive to three different wavelengths of light. Hence the need to use three numbers to describe color. Be glad you are not a mantis shrimp as those are sensitive to 12 different wavelengths, so instead of RGB we would be using the ABCDEFGHIJKL colorspace...
Color exists only in the eye and brain and is the result of how strongly color receptors are stimulated. This is based on the Spectral Power Distribution (SPD) which is a graph showing the intensity (radiant power) of the light at wavelengths covering the visible spectrum as it enters the eye. The science of colorimetry is about the relationship between the SPD and color as perceived by the human brain.
Since the human eye has only three color receptors it is perfectly possible that different SPDs will result in the same stimulation of those receptors and are perceived as the same color, even though the SPD of the light is different.
In the 1920s experiments were devised to determine the relationship between SPDs and the perceived color and that resulted in the CIE 1931 standard that defines spectral weighting functions that model the perception of color. Specifically that standard defines functions that can take an SPD and calculate the stimulus for each color receptor. After some further mathematical transforms these stimuli are known as the CIE XYZ tristimulus values and these X, Y and Z values describe a color as perceived by a human unambiguously. These X, Y and Z values are all in the range [0…1].
The Y value in the CIE XYZ colorspace corresponds to luminance. Often the CIE XYZ colorspace is transformed to the normalized CIE xyY colorspace:
x = X / (X + Y + Z)
y = Y / (X + Y + Z)
The x and y values are the chromaticity coordinates and can be used to define a color without the luminance component Y. It is very confusing to have such similar names for these colorspaces. Just be aware that if colors are specified with lower case 'x' and 'y', then the CIE xyY colorspace is used. Upper case 'X' and 'Y' refer to the CIE XYZ colorspace. Also, y has nothing to do with luminance. Together x and y specify a color, and Y the luminance. That is really all you need to remember from a practical point of view. At the end of this section you will find reading resources that go into much more detail if you are interested.
A monitor or TV will reproduce colors by emitting light at three different wavelengths, the combination of which will stimulate the color receptors in the eye and thus cause the perception of color. Historically these wavelengths were defined by the red, green and blue phosphors used in the displays. These color primaries are part of what defines a colorspace.
Different display devices will have different primaries and some primaries are more suitable for some display technologies than others. This has resulted in a variety of colorspaces that are used for different display technologies or uses. To define a colorspace you need to define the three color primaries (these are typically defined as x, y chromaticity coordinates from the CIE xyY colorspace) but also the white reference: that is the color obtained when all three primaries are at maximum power. This determines the relative power or energy of the primaries. This is usually chosen to be close to daylight which has been defined as the CIE D65 Illuminant.
To recapitulate: the CIE XYZ colorspace uniquely identifies colors. Other colorspaces are defined by three chromaticity coordinates defined in the CIE xyY colorspace. Based on those a 3x3 matrix can be constructed that transforms CIE XYZ colors to colors in the new colorspace.
Both the CIE XYZ and the RGB colorspace that are derived from the specific chromaticity primaries are linear colorspaces. But neither the eye, nor display technology is linear. Doubling the values of all components in the linear colorspace will not be perceived as twice the intensity of the color. So each colorspace also defines a transfer function that takes a linear color component value and transforms it to the non-linear component value, which is a closer match to the non-linear performance of both the eye and displays. Linear component values are denoted RGB, non-linear are denoted as R'G'B'. In general colors used in graphics are all R'G'B', except in openGL which uses linear RGB. Special care should be taken when dealing with openGL to provide linear RGB colors or to use the built-in openGL support to apply the inverse transfer function.
The final piece that defines a colorspace is a function that transforms non-linear R'G'B' to non-linear Y'CbCr. This function is determined by the so-called luma coefficients. There may be multiple possible Y'CbCr encodings allowed for the same colorspace. Many encodings of color prefer to use luma (Y') and chroma (CbCr) instead of R'G'B'. Since the human eye is more sensitive to differences in luminance than in color this encoding allows one to reduce the amount of color information compared to the luma data. Note that the luma (Y') is unrelated to the Y in the CIE XYZ colorspace. Also note that Y'CbCr is often called YCbCr or YUV even though these are strictly speaking wrong.
Sometimes people confuse Y'CbCr as being a colorspace. This is not correct, it is just an encoding of an R'G'B' color into luma and chroma values. The underlying colorspace that is associated with the R'G'B' color is also associated with the Y'CbCr color.
The final step is how the RGB, R'G'B' or Y'CbCr values are quantized. The CIE XYZ colorspace where X, Y and Z are in the range [0…1] describes all colors that humans can perceive, but the transform to another colorspace will produce colors that are outside the [0…1] range. Once clamped to the [0…1] range those colors can no longer be reproduced in that colorspace. This clamping is what reduces the extent or gamut of the colorspace. How the range of [0…1] is translated to integer values in the range of [0…255] (or higher, depending on the color depth) is called the quantization. This is not part of the colorspace definition. In practice RGB or R'G'B' values are full range, i.e. they use the full [0…255] range. Y'CbCr values on the other hand are limited range with Y' using [16…235] and Cb and Cr using [16…240].
Unfortunately, in some cases limited range RGB is also used where the components use the range [16…235]. And full range Y'CbCr also exists using the [0…255] range.
In order to correctly interpret a color you need to know the quantization range, whether it is R'G'B' or Y'CbCr, the used Y'CbCr encoding and the colorspace. From that information you can calculate the corresponding CIE XYZ color and map that again to whatever colorspace your display device uses.
The colorspace definition itself consists of the three chromaticity primaries, the white reference chromaticity, a transfer function and the luma coefficients needed to transform R'G'B' to Y'CbCr. While some colorspace standards correctly define all four, quite often the colorspace standard only defines some, and you have to rely on other standards for the missing pieces. The fact that colorspaces are often a mix of different standards also led to very confusing naming conventions where the name of a standard was used to name a colorspace when in fact that standard was part of various other colorspaces as well.
If you want to read more about colors and colorspaces, then the following resources are useful: poynton is a good practical book for video engineers, colimg has a much broader scope and describes many more aspects of color (physics, chemistry, biology, etc.). The http://www.brucelindbloom.com website is an excellent resource, especially with respect to the mathematics behind colorspace conversions. The wikipedia CIE 1931 colorspace article is also very useful.
Common definitions for V4L2 and V4L2 subdev interfaces
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Common API Elements
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Programming a V4L2 device consists of these steps:
-
Opening the device
-
Changing device properties, selecting a video and audio input, video standard, picture brightness a. o.
-
Negotiating a data format
-
Negotiating an input/output method
-
The actual input/output loop
-
Closing the device
In practice most steps are optional and can be executed out of order. It depends on the V4L2 device type, you can read about the details in Interfaces. In this chapter we will discuss the basic concepts applicable to all devices.
- Opening and Closing Devices
- Querying Capabilities
- Application Priority
- Video Inputs and Outputs
- Audio Inputs and Outputs
- Tuners and Modulators
- Video Standards
- Digital Video (DV) Timings
- User Controls
- Extended Controls API
- ext-ctrls-camera
- Flash Control Reference
- Image Source Control Reference
- Image Process Control Reference
- ext-ctrls-codec
- ext-ctrls-codec-stateless
- JPEG Control Reference
- Digital Video Control Reference
- RF Tuner Control Reference
- FM Transmitter Control Reference
- FM Receiver Control Reference
- Detect Control Reference
- Colorimetry Control Reference
- Guidelines for Video4Linux pixel format 4CCs
- Data Formats
- Single- and multi-planar APIs
- Cropping, composing and scaling -- the SELECTION API
- Image Cropping, Insertion and Scaling -- the CROP API
- Streaming Parameters
Changes
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The following chapters document the evolution of the V4L2 API, errata or extensions. They are also intended to help application and driver writers to port or update their code.
User Controls
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Devices typically have a number of user-settable controls such as brightness, saturation and so on, which would be presented to the user on a graphical user interface. But, different devices will have different controls available, and furthermore, the range of possible values, and the default value will vary from device to device. The control ioctls provide the information and a mechanism to create a nice user interface for these controls that will work correctly with any device.
All controls are accessed using an ID value. V4L2 defines several IDs for specific purposes. Drivers can also implement their own custom controls using V4L2_CID_PRIVATE_BASE 1 and higher values. The pre-defined control IDs have the prefix V4L2_CID_, and are listed in Control IDs. The ID is used when querying the attributes of a control, and when getting or setting the current value.
Generally applications should present controls to the user without assumptions about their purpose. Each control comes with a name string the user is supposed to understand. When the purpose is non-intuitive the driver writer should provide a user manual, a user interface plug-in or a driver specific panel application. Predefined IDs were introduced to change a few controls programmatically, for example to mute a device during a channel switch.
Drivers may enumerate different controls after switching the current video input or output, tuner or modulator, or audio input or output. Different in the sense of other bounds, another default and current value, step size or other menu items. A control with a certain custom ID can also change name and type.
If a control is not applicable to the current configuration of the device (for example, it doesn't apply to the current video input) drivers set the V4L2_CTRL_FLAG_INACTIVE flag.
Control values are stored globally, they do not change when switching except to stay within the reported bounds. They also do not change e. g. when the device is opened or closed, when the tuner radio frequency is changed or generally never without application request.
V4L2 specifies an event mechanism to notify applications when controls change value (see ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT, event V4L2_EVENT_CTRL), panel applications might want to make use of that in order to always reflect the correct control value.
All controls use machine endianness.
Control IDs #
-
V4L2_CID_BASEFirst predefined ID, equal to
V4L2_CID_BRIGHTNESS. -
V4L2_CID_USER_BASESynonym of
V4L2_CID_BASE. -
V4L2_CID_BRIGHTNESS(integer)Picture brightness, or more precisely, the black level.
-
V4L2_CID_CONTRAST(integer)Picture contrast or luma gain.
-
V4L2_CID_SATURATION(integer)Picture color saturation or chroma gain.
-
V4L2_CID_HUE(integer)Hue or color balance.
-
V4L2_CID_AUDIO_VOLUME(integer)Overall audio volume. Note some drivers also provide an OSS or ALSA mixer interface.
-
V4L2_CID_AUDIO_BALANCE(integer)Audio stereo balance. Minimum corresponds to all the way left, maximum to right.
-
V4L2_CID_AUDIO_BASS(integer)Audio bass adjustment.
-
V4L2_CID_AUDIO_TREBLE(integer)Audio treble adjustment.
-
V4L2_CID_AUDIO_MUTE(boolean)Mute audio, i. e. set the volume to zero, however without affecting
V4L2_CID_AUDIO_VOLUME. Like ALSA drivers, V4L2 drivers must mute at load time to avoid excessive noise. Actually the entire device should be reset to a low power consumption state. -
V4L2_CID_AUDIO_LOUDNESS(boolean)Loudness mode (bass boost).
-
V4L2_CID_BLACK_LEVEL(integer)Another name for brightness (not a synonym of
V4L2_CID_BRIGHTNESS). This control is deprecated and should not be used in new drivers and applications. -
V4L2_CID_AUTO_WHITE_BALANCE(boolean)Automatic white balance (cameras).
-
V4L2_CID_DO_WHITE_BALANCE(button)This is an action control. When set (the value is ignored), the device will do a white balance and then hold the current setting. Contrast this with the boolean
V4L2_CID_AUTO_WHITE_BALANCE, which, when activated, keeps adjusting the white balance. -
V4L2_CID_RED_BALANCE(integer)Red chroma balance.
-
V4L2_CID_BLUE_BALANCE(integer)Blue chroma balance.
-
V4L2_CID_GAMMA(integer)Gamma adjust.
-
V4L2_CID_WHITENESS(integer)Whiteness for grey-scale devices. This is a synonym for
V4L2_CID_GAMMA. This control is deprecated and should not be used in new drivers and applications. -
V4L2_CID_EXPOSURE(integer)Exposure (cameras). [Unit?]
-
V4L2_CID_AUTOGAIN(boolean)Automatic gain/exposure control.
-
V4L2_CID_GAIN(integer)Gain control.
Primarily used to control gain on e.g. TV tuners but also on webcams. Most devices control only digital gain with this control but on some this could include analogue gain as well. Devices that recognise the difference between digital and analogue gain use controls
V4L2_CID_DIGITAL_GAINandV4L2_CID_ANALOGUE_GAIN.
-
V4L2_CID_HFLIP(boolean)Mirror the picture horizontally.
-
V4L2_CID_VFLIP(boolean)Mirror the picture vertically.
-
V4L2_CID_POWER_LINE_FREQUENCY(enum)Enables a power line frequency filter to avoid flicker. Possible values for
enum v4l2_power_line_frequencyare:V4L2_CID_POWER_LINE_FREQUENCY_DISABLED0
V4L2_CID_POWER_LINE_FREQUENCY_50HZ1
V4L2_CID_POWER_LINE_FREQUENCY_60HZ2
V4L2_CID_POWER_LINE_FREQUENCY_AUTO3
-
V4L2_CID_HUE_AUTO(boolean)Enables automatic hue control by the device. The effect of setting
V4L2_CID_HUEwhile automatic hue control is enabled is undefined, drivers should ignore such request. -
V4L2_CID_WHITE_BALANCE_TEMPERATURE(integer)This control specifies the white balance settings as a color temperature in Kelvin. A driver should have a minimum of 2800 (incandescent) to 6500 (daylight). For more information about color temperature see Wikipedia.
-
V4L2_CID_SHARPNESS(integer)Adjusts the sharpness filters in a camera. The minimum value disables the filters, higher values give a sharper picture.
-
V4L2_CID_BACKLIGHT_COMPENSATION(integer)Adjusts the backlight compensation in a camera. The minimum value disables backlight compensation.
-
V4L2_CID_CHROMA_AGC(boolean)Chroma automatic gain control.
-
V4L2_CID_CHROMA_GAIN(integer)Adjusts the Chroma gain control (for use when chroma AGC is disabled).
-
V4L2_CID_COLOR_KILLER(boolean)Enable the color killer (i. e. force a black & white image in case of a weak video signal).
-
V4L2_CID_COLORFX(enum)Selects a color effect. The following values are defined:
|
|
Color effect is disabled. |
|
|
An aging (old photo) effect. |
|
|
Frost color effect. |
|
|
Water color, cool tone. |
|
|
Black and white. |
|
|
Emboss, the highlights and shadows replace light/dark boundaries and low contrast areas are set to a gray background. |
|
|
Grass green. |
|
|
Negative. |
|
|
Sepia tone. |
|
|
Sketch. |
|
|
Skin whiten. |
|
|
Sky blue. |
|
|
Solarization, the image is partially reversed in tone, only color values above or below a certain threshold are inverted. |
|
|
Silhouette (outline). |
|
|
Vivid colors. |
|
|
The Cb and Cr chroma components are replaced by fixed coefficients determined by |
|
|
The RGB components are replaced by the fixed RGB components determined by |
-
V4L2_CID_COLORFX_RGB(integer)Determines the Red, Green, and Blue coefficients for
V4L2_COLORFX_SET_RGBcolor effect. Bits [7:0] of the supplied 32 bit value are interpreted as Blue component, bits [15:8] as Green component, bits [23:16] as Red component, and bits [31:24] must be zero. -
V4L2_CID_COLORFX_CBCR(integer)Determines the Cb and Cr coefficients for
V4L2_COLORFX_SET_CBCRcolor effect. Bits [7:0] of the supplied 32 bit value are interpreted as Cr component, bits [15:8] as Cb component and bits [31:16] must be zero. -
V4L2_CID_AUTOBRIGHTNESS(boolean)Enable Automatic Brightness.
-
V4L2_CID_ROTATE(integer)Rotates the image by specified angle. Common angles are 90, 270 and 180. Rotating the image to 90 and 270 will reverse the height and width of the display window. It is necessary to set the new height and width of the picture using the VIDIOC_S_FMT ioctl according to the rotation angle selected.
-
V4L2_CID_BG_COLOR(integer)Sets the background color on the current output device. Background color needs to be specified in the RGB24 format. The supplied 32 bit value is interpreted as bits 0-7 Red color information, bits 8-15 Green color information, bits 16-23 Blue color information and bits 24-31 must be zero.
-
V4L2_CID_ILLUMINATORS_1 V4L2_CID_ILLUMINATORS_2(boolean)Switch on or off the illuminator 1 or 2 of the device (usually a microscope).
-
V4L2_CID_MIN_BUFFERS_FOR_CAPTURE(integer)This is a read-only control that can be read by the application and used as a hint to determine the number of CAPTURE buffers to pass to REQBUFS. The value is the minimum number of CAPTURE buffers that is necessary for hardware to work. This control is required for stateful decoders.
-
V4L2_CID_MIN_BUFFERS_FOR_OUTPUT(integer)This is a read-only control that can be read by the application and used as a hint to determine the number of OUTPUT buffers to pass to REQBUFS. The value is the minimum number of OUTPUT buffers that is necessary for hardware to work. This control is required for stateful encoders.
-
V4L2_CID_ALPHA_COMPONENT(integer)Sets the alpha color component. When a capture device (or capture queue of a mem-to-mem device) produces a frame format that includes an alpha component (e.g. packed RGB image formats) and the alpha value is not defined by the device or the mem-to-mem input data this control lets you select the alpha component value of all pixels. When an output device (or output queue of a mem-to-mem device) consumes a frame format that doesn't include an alpha component and the device supports alpha channel processing this control lets you set the alpha component value of all pixels for further processing in the device.
-
V4L2_CID_LASTP1End of the predefined control IDs (currently
V4L2_CID_ALPHA_COMPONENT+ 1). -
V4L2_CID_PRIVATE_BASEID of the first custom (driver specific) control. Applications depending on particular custom controls should check the driver name and version, see Querying Capabilities.
Applications can enumerate the available controls with the vidioc_queryctrl and VIDIOC_QUERYMENU ioctls, get and set a control value with the VIDIOC_G_CTRL and VIDIOC_S_CTRL ioctls. Drivers must implement VIDIOC_QUERYCTRL, VIDIOC_G_CTRL and VIDIOC_S_CTRL when the device has one or more controls, VIDIOC_QUERYMENU when it has one or more menu type controls.
Example: Enumerating all controls #
struct v4l2_queryctrl queryctrl;
struct v4l2_querymenu querymenu;
static void
;
queryctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
while
if
Example: Enumerating all controls including compound controls #
struct v4l2_query_ext_ctrl query_ext_ctrl;
;
query_ext_ctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL | V4L2_CTRL_FLAG_NEXT_COMPOUND;
while
if
Example: Enumerating all user controls (old style) #
;
for
for
Example: Changing controls #
struct v4l2_queryctrl queryctrl;
struct v4l2_control control;
;
queryctrl.id = V4L2_CID_BRIGHTNESS;
if else if else
;
control.id = V4L2_CID_CONTRAST;
if else if
control.id = V4L2_CID_AUDIO_MUTE;
control.value = 1; /* silence */
/* Errors ignored */
;
[1] The use of V4L2_CID_PRIVATE_BASE is problematic because different drivers may use the same V4L2_CID_PRIVATE_BASE ID for different controls. This makes it hard to programmatically set such controls since the meaning of the control with that ID is driver dependent. In order to resolve this drivers use unique IDs and the V4L2_CID_PRIVATE_BASE IDs are mapped to those unique IDs by the kernel. Consider these V4L2_CID_PRIVATE_BASE IDs as aliases to the real IDs.
Many applications today still use the V4L2_CID_PRIVATE_BASE IDs instead of using vidioc_queryctrl with the V4L2_CTRL_FLAG_NEXT_CTRL flag to enumerate all IDs, so support for V4L2_CID_PRIVATE_BASE is still around.
Image Cropping, Insertion and Scaling -- the CROP API
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Some video capture devices can sample a subsection of the picture and shrink or enlarge it to an image of arbitrary size. We call these abilities cropping and scaling. Some video output devices can scale an image up or down and insert it at an arbitrary scan line and horizontal offset into a video signal.
Applications can use the following API to select an area in the video signal, query the default area and the hardware limits.
Scaling requires a source and a target. On a video capture or overlay device the source is the video signal, and the cropping ioctls determine the area actually sampled. The target are images read by the application or overlaid onto the graphics screen. Their size (and position for an overlay) is negotiated with the VIDIOC_G_FMT and VIDIOC_S_FMT ioctls.
On a video output device the source are the images passed in by the application, and their size is again negotiated with the VIDIOC_G_FMT and VIDIOC_S_FMT ioctls, or may be encoded in a compressed video stream. The target is the video signal, and the cropping ioctls determine the area where the images are inserted.
Source and target rectangles are defined even if the device does not support scaling or the VIDIOC_G_CROP and VIDIOC_S_CROP ioctls. Their size (and position where applicable) will be fixed in this case.
Cropping Structures #
Image Cropping, Insertion and Scaling
The cropping, insertion and scaling process
For capture devices the coordinates of the top left corner, width and height of the area which can be sampled is given by the bounds substructure of the struct v4l2_cropcap returned by the VIDIOC_CROPCAP ioctl. To support a wide range of hardware this specification does not define an origin or units. However by convention drivers should horizontally count unscaled samples relative to 0H (the leading edge of the horizontal sync pulse, see vbi-hsync). Vertically ITU-R line numbers of the first field (see ITU R-525 line numbering for 525 lines and for 625 lines), multiplied by two if the driver can capture both fields.
The top left corner, width and height of the source rectangle, that is the area actually sampled, is given by struct v4l2_crop using the same coordinate system as struct v4l2_cropcap. Applications can use the VIDIOC_G_CROP and VIDIOC_S_CROP ioctls to get and set this rectangle. It must lie completely within the capture boundaries and the driver may further adjust the requested size and/or position according to hardware limitations.
Each capture device has a default source rectangle, given by the defrect substructure of struct v4l2_cropcap. The center of this rectangle shall align with the center of the active picture area of the video signal, and cover what the driver writer considers the complete picture. Drivers shall reset the source rectangle to the default when the driver is first loaded, but not later.
For output devices these structures and ioctls are used accordingly, defining the target rectangle where the images will be inserted into the video signal.
Scaling Adjustments #
Video hardware can have various cropping, insertion and scaling limitations. It may only scale up or down, support only discrete scaling factors, or have different scaling abilities in horizontal and vertical direction. Also it may not support scaling at all. At the same time the struct v4l2_crop rectangle may have to be aligned, and both the source and target rectangles may have arbitrary upper and lower size limits. In particular the maximum width and height in struct v4l2_crop may be smaller than the struct v4l2_cropcap. bounds area. Therefore, as usual, drivers are expected to adjust the requested parameters and return the actual values selected.
Applications can change the source or the target rectangle first, as they may prefer a particular image size or a certain area in the video signal. If the driver has to adjust both to satisfy hardware limitations, the last requested rectangle shall take priority, and the driver should preferably adjust the opposite one. The VIDIOC_TRY_FMT ioctl however shall not change the driver state and therefore only adjust the requested rectangle.
Suppose scaling on a video capture device is restricted to a factor 1:1 or 2:1 in either direction and the target image size must be a multiple of 16 × 16 pixels. The source cropping rectangle is set to defaults, which are also the upper limit in this example, of 640 × 400 pixels at offset 0, 0. An application requests an image size of 300 × 225 pixels, assuming video will be scaled down from the "full picture" accordingly. The driver sets the image size to the closest possible values 304 × 224, then chooses the cropping rectangle closest to the requested size, that is 608 × 224 (224 × 2:1 would exceed the limit 400). The offset 0, 0 is still valid, thus unmodified. Given the default cropping rectangle reported by VIDIOC_CROPCAP the application can easily propose another offset to center the cropping rectangle.
Now the application may insist on covering an area using a picture aspect ratio closer to the original request, so it asks for a cropping rectangle of 608 × 456 pixels. The present scaling factors limit cropping to 640 × 384, so the driver returns the cropping size 608 × 384 and adjusts the image size to closest possible 304 × 192.
Examples #
Source and target rectangles shall remain unchanged across closing and reopening a device, such that piping data into or out of a device will work without special preparations. More advanced applications should ensure the parameters are suitable before starting I/O.
Example: Resetting the cropping parameters #
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
;
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if
;
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
crop.c = cropcap.defrect;
/* Ignore if cropping is not supported (EINVAL). */
if
Example: Simple downscaling #
struct v4l2_cropcap cropcap;
struct v4l2_format format;
;
/* Scale down to 1/4 size of full picture. */
; /* defaults */
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
format.fmt.pix.width = cropcap.defrect.width >> 1;
format.fmt.pix.height = cropcap.defrect.height >> 1;
format.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
if
/* We could check the actual image size now, the actual scaling factor
or if the driver can scale at all. */
Example: Selecting an output area #
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
;
cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
if
;
crop.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
crop.c = cropcap.defrect;
/* Scale the width and height to 50 % of their original size
and center the output. */
crop.c.width /= 2;
crop.c.height /= 2;
crop.c.left += crop.c.width / 2;
crop.c.top += crop.c.height / 2;
/* Ignore if cropping is not supported (EINVAL). */
if
Example: Current scaling factor and pixel aspect #
struct v4l2_cropcap cropcap;
struct v4l2_crop crop;
struct v4l2_format format;
double hscale, vscale;
double aspect;
int dwidth, dheight;
;
cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if
;
crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if
;
format.fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if
/* The scaling applied by the driver. */
hscale = format.fmt.pix.width / crop.c.width;
vscale = format.fmt.pix.height / crop.c.height;
aspect = cropcap.pixelaspect.numerator /
cropcap.pixelaspect.denominator;
aspect = aspect * hscale / vscale;
/* Devices following ITU-R BT.601 do not capture
square pixels. For playback on a computer monitor
we should scale the images to this size. */
dwidth = format.fmt.pix.width / aspect;
dheight = format.fmt.pix.height;
Depth Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Depth data provides distance to points, mapped onto the image plane
Video Capture Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Video capture devices sample an analog video signal and store the digitized images in memory. Today nearly all devices can capture at full 25 or 30 frames/second. With this interface applications can control the capture process and move images from the driver into user space.
Conventionally V4L2 video capture devices are accessed through character device special files named /dev/video and /dev/video0 to /dev/video63 with major number 81 and minor numbers 0 to 63. /dev/video is typically a symbolic link to the preferred video device.
Querying Capabilities #
Devices supporting the video capture interface set the V4L2_CAP_VIDEO_CAPTURE or V4L2_CAP_VIDEO_CAPTURE_MPLANE flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. As secondary device functions they may also support the video overlay (V4L2_CAP_VIDEO_OVERLAY) and the raw VBI capture (V4L2_CAP_VBI_CAPTURE) interface. At least one of the read/write or streaming I/O methods must be supported. Tuners and audio inputs are optional.
Supplemental Functions #
Video capture devices shall support audio input, Tuners and Modulators, controls, cropping and scaling and streaming parameter ioctls as needed. The video input ioctls must be supported by all video capture devices.
Image Format Negotiation #
The result of a capture operation is determined by cropping and image format parameters. The former select an area of the video picture to capture, the latter how images are stored in memory, i. e. in RGB or YUV format, the number of bits per pixel or width and height. Together they also define how images are scaled in the process.
As usual these parameters are not reset at open() time to permit Unix tool chains, programming a device and then reading from it as if it was a plain file. Well written V4L2 applications ensure they really get what they want, including cropping and scaling.
Cropping initialization at minimum requires to reset the parameters to defaults. An example is given in Image Cropping, Insertion and Scaling -- the CROP API.
To query the current image format applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VIDEO_CAPTURE or V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE and call the VIDIOC_G_FMT ioctl with a pointer to this structure. Drivers fill the struct v4l2_pix_format pix or the struct v4l2_pix_format_mplane pix_mp member of the fmt union.
To request different parameters applications set the type field of a struct v4l2_format as above and initialize all fields of the struct v4l2_pix_format vbi member of the fmt union, or better just modify the results of VIDIOC_G_FMT, and call the VIDIOC_S_FMT ioctl with a pointer to this structure. Drivers may adjust the parameters and finally return the actual parameters as VIDIOC_G_FMT does.
Like VIDIOC_S_FMT the VIDIOC_TRY_FMT ioctl can be used to learn about hardware limitations without disabling I/O or possibly time consuming hardware preparations.
The contents of struct v4l2_pix_format and struct v4l2_pix_format_mplane are discussed in Image Formats. See also the specification of the VIDIOC_G_FMT, VIDIOC_S_FMT and VIDIOC_TRY_FMT ioctls for details. Video capture devices must implement both the VIDIOC_G_FMT and VIDIOC_S_FMT ioctl, even if VIDIOC_S_FMT ignores all requests and always returns default parameters as VIDIOC_G_FMT does. VIDIOC_TRY_FMT is optional.
Reading Images #
A video capture device may support the read() function and/or streaming (memory mapping or user pointer) I/O. See Input/Output for details.
Memory-to-Memory Stateful Video Decoder Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
A stateful video decoder takes complete chunks of the bytestream (e.g. Annex-B H.264/HEVC stream, raw VP8/9 stream) and decodes them into raw video frames in display order. The decoder is expected not to require any additional information from the client to process these buffers.
Performing software parsing, processing etc. of the stream in the driver in order to support this interface is strongly discouraged. In case such operations are needed, use of the Stateless Video Decoder Interface (in development) is strongly advised.
Conventions and Notations Used in This Document #
-
The general V4L2 API rules apply if not specified in this document otherwise.
-
The meaning of words "must", "may", "should", etc. is as per RFC 2119.
-
All steps not marked "optional" are required.
-
VIDIOC_G_EXT_CTRLS()andVIDIOC_S_EXT_CTRLS()may be used interchangeably withVIDIOC_G_CTRL()andVIDIOC_S_CTRL(), unless specified otherwise. -
Single-planar API (see Single- and multi-planar APIs) and applicable structures may be used interchangeably with multi-planar API, unless specified otherwise, depending on decoder capabilities and following the general V4L2 guidelines.
-
i = [a..b]: sequence of integers from a to b, inclusive, i.e. i = [0..2]: i = 0, 1, 2.
-
Given an
OUTPUTbuffer A, then A' represents a buffer on theCAPTUREqueue containing data that resulted from processing buffer A.
Glossary #
-
CAPTURE
the destination buffer queue; for decoders, the queue of buffers containing decoded frames; for encoders, the queue of buffers containing an encoded bytestream;
V4L2_BUF_TYPE_VIDEO_CAPTUREorV4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; data is captured from the hardware intoCAPTUREbuffers. -
client
the application communicating with the decoder or encoder implementing this interface.
-
coded format
encoded/compressed video bytestream format (e.g. H.264, VP8, etc.); see also: raw format.
-
coded height
height for given coded resolution.
-
coded resolution
stream resolution in pixels aligned to codec and hardware requirements; typically visible resolution rounded up to full macroblocks; see also: visible resolution.
-
coded width
width for given coded resolution.
-
coding tree unit
processing unit of the HEVC codec (corresponds to macroblock units in H.264, VP8, VP9), can use block structures of up to 64×64 pixels. Good at sub-partitioning the picture into variable sized structures.
-
decode order
the order in which frames are decoded; may differ from display order if the coded format includes a feature of frame reordering; for decoders,
OUTPUTbuffers must be queued by the client in decode order; for encodersCAPTUREbuffers must be returned by the encoder in decode order. -
destination
data resulting from the decode process; see
CAPTURE. -
display order
the order in which frames must be displayed; for encoders,
OUTPUTbuffers must be queued by the client in display order; for decoders,CAPTUREbuffers must be returned by the decoder in display order. -
DPB
Decoded Picture Buffer; an H.264/HEVC term for a buffer that stores a decoded raw frame available for reference in further decoding steps.
-
EOS
end of stream.
-
IDR
Instantaneous Decoder Refresh; a type of a keyframe in an H.264/HEVC-encoded stream, which clears the list of earlier reference frames (DPBs).
-
keyframe
an encoded frame that does not reference frames decoded earlier, i.e. can be decoded fully on its own.
-
macroblock
a processing unit in image and video compression formats based on linear block transforms (e.g. H.264, VP8, VP9); codec-specific, but for most of popular codecs the size is 16x16 samples (pixels). The HEVC codec uses a slightly more flexible processing unit called coding tree unit (CTU).
-
OUTPUT
the source buffer queue; for decoders, the queue of buffers containing an encoded bytestream; for encoders, the queue of buffers containing raw frames;
V4L2_BUF_TYPE_VIDEO_OUTPUTorV4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; the hardware is fed with data fromOUTPUTbuffers. -
PPS
Picture Parameter Set; a type of metadata entity in an H.264/HEVC bytestream.
-
raw format
uncompressed format containing raw pixel data (e.g. YUV, RGB formats).
-
resume point
a point in the bytestream from which decoding may start/continue, without any previous state/data present, e.g.: a keyframe (VP8/VP9) or SPS/PPS/IDR sequence (H.264/HEVC); a resume point is required to start decode of a new stream, or to resume decoding after a seek.
-
source
data fed to the decoder or encoder; see
OUTPUT. -
source height
height in pixels for given source resolution; relevant to encoders only.
-
source resolution
resolution in pixels of source frames being source to the encoder and subject to further cropping to the bounds of visible resolution; relevant to encoders only.
-
source width
width in pixels for given source resolution; relevant to encoders only.
-
SPS
Sequence Parameter Set; a type of metadata entity in an H.264/HEVC bytestream.
-
stream metadata
additional (non-visual) information contained inside encoded bytestream; for example: coded resolution, visible resolution, codec profile.
-
visible height
height for given visible resolution; display height.
-
visible resolution
stream resolution of the visible picture, in pixels, to be used for display purposes; must be smaller or equal to coded resolution; display resolution.
-
visible width
width for given visible resolution; display width.
State Machine #
flowchart TB
n0((("Decoding")))
n1(("Initialization"))
n2(("Capture<br/>setup"))
n3(("Dynamic<br/>Resolution<br/>Change"))
n4(("Stopped"))
n5(("Drain"))
n6(("Seek"))
n7(("End of Stream"))
n8(("#160;"))
n8 -->|"open()"| n1
n1 -->|"CAPTURE<br/>format<br/>established"| n2
n2 -->|"CAPTURE<br/>buffers<br/>ready"| n4
n0 -->|"Stream<br/>resolution<br/>change"| n3
n0 -->|"V4L2_DEC_CMD_STOP"| n5
n0 -->|"EoS mark<br/>in the stream"| n7
n0 -->|"VIDIOC_STREAMOFF(OUTPUT)"| n6
n0 -->|"VIDIOC_STREAMOFF(CAPTURE)"| n4
n0 --> n0
n3 -->|"CAPTURE<br/>format<br/>established"| n2
n3 -->|"VIDIOC_STREAMOFF(OUTPUT)"| n6
n7 -->|"Implicit<br/>drain"| n5
n5 -->|"All CAPTURE<br/>buffers dequeued<br/>or<br/>VIDIOC_STREAMOFF(CAPTURE)"| n4
n5 -->|"VIDIOC_STREAMOFF(OUTPUT)"| n6
n6 -->|"VIDIOC_STREAMON(OUTPUT)"| n0
n6 -->|"VIDIOC_REQBUFS(OUTPUT, 0)"| n1
n4 -->|"V4L2_DEC_CMD_START<br/>or<br/>VIDIOC_STREAMON(CAPTURE)"| n0
n4 -->|"VIDIOC_STREAMOFF(OUTPUT)"| n6
style n8 fill:#333,stroke:#333
Decoder State Machine
Querying Capabilities #
-
To enumerate the set of coded formats supported by the decoder, the client may call
VIDIOC_ENUM_FMT()onOUTPUT.-
The full set of supported formats will be returned, regardless of the format set on
CAPTURE. -
Check the flags field of
v4l2_fmtdescfor more information about the decoder's capabilities with respect to each coded format. In particular whether or not the decoder has a full-fledged bytestream parser and if the decoder supports dynamic resolution changes.
-
-
To enumerate the set of supported raw formats, the client may call
VIDIOC_ENUM_FMT()onCAPTURE.-
Only the formats supported for the format currently active on
OUTPUTwill be returned. -
In order to enumerate raw formats supported by a given coded format, the client must first set that coded format on
OUTPUTand then enumerate formats onCAPTURE.
-
-
The client may use
VIDIOC_ENUM_FRAMESIZES()to detect supported resolutions for a given format, passing desired pixel format inv4l2_frmsizeenumpixel_format.-
Values returned by
VIDIOC_ENUM_FRAMESIZES()for a coded pixel format will include all possible coded resolutions supported by the decoder for given coded pixel format. -
Values returned by
VIDIOC_ENUM_FRAMESIZES()for a raw pixel format will include all possible frame buffer resolutions supported by the decoder for given raw pixel format and the coded format currently set onOUTPUT.
-
-
Supported profiles and levels for the coded format currently set on
OUTPUT, if applicable, may be queried using their respective controls viaVIDIOC_QUERYCTRL().
Initialization #
-
Set the coded format on
OUTPUTviaVIDIOC_S_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
pixelformata coded pixel format.
-
width,heightcoded resolution of the stream; required only if it cannot be parsed from the stream for the given coded format; otherwise the decoder will use this resolution as a placeholder resolution that will likely change as soon as it can parse the actual coded resolution from the stream.
-
sizeimagedesired size of
OUTPUTbuffers; the decoder may adjust it to match hardware requirements. -
other fields
follow standard semantics.
-
-
Returned fields:
-
sizeimageadjusted size of
OUTPUTbuffers.
-
-
The
CAPTUREformat will be updated with an appropriate frame buffer resolution instantly based on the width and height returned byVIDIOC_S_FMT(). However, for coded formats that include stream resolution information, after the decoder is done parsing the information from the stream, it will update theCAPTUREformat with new values and signal a source change event, regardless of whether they match the values set by the client or not.
-
-
Allocate source (bytestream) buffers via
VIDIOC_REQBUFS()onOUTPUT.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
memoryfollows standard semantics.
-
-
Returned fields:
-
countthe actual number of buffers allocated.
-
Alternatively,
VIDIOC_CREATE_BUFS()on theOUTPUTqueue can be used to have more control over buffer allocation.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
memoryfollows standard semantics.
-
formatfollows standard semantics.
-
-
Returned fields:
-
countadjusted to the number of allocated buffers.
-
-
-
Start streaming on the
OUTPUTqueue viaVIDIOC_STREAMON(). -
This step only applies to coded formats that contain resolution information in the stream. Continue queuing/dequeuing bytestream buffers to/from the
OUTPUTqueue viaVIDIOC_QBUF()andVIDIOC_DQBUF(). The buffers will be processed and returned to the client in order, until required metadata to configure theCAPTUREqueue are found. This is indicated by the decoder sending aV4L2_EVENT_SOURCE_CHANGEevent withchangesset toV4L2_EVENT_SRC_CH_RESOLUTION.-
It is not an error if the first buffer does not contain enough data for this to occur. Processing of the buffers will continue as long as more data is needed.
-
If data in a buffer that triggers the event is required to decode the first frame, it will not be returned to the client, until the initialization sequence completes and the frame is decoded.
-
If the client has not set the coded resolution of the stream on its own, calling
VIDIOC_G_FMT(),VIDIOC_S_FMT(),VIDIOC_TRY_FMT()orVIDIOC_REQBUFS()on theCAPTUREqueue will not return the real values for the stream until aV4L2_EVENT_SOURCE_CHANGEevent withchangesset toV4L2_EVENT_SRC_CH_RESOLUTIONis signaled.
-
-
Continue with the
Capture Setupsequence.
Capture Setup #
-
Call
VIDIOC_G_FMT()on theCAPTUREqueue to get format for the destination buffers parsed/decoded from the bytestream.-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE.
-
-
Returned fields:
-
width,heightframe buffer resolution for the decoded frames.
-
pixelformatpixel format for decoded frames.
-
num_planes(for _MPLANEtypeonly)number of planes for pixelformat.
-
sizeimage,bytesperlineas per standard semantics; matching frame buffer format.
-
-
-
Optional. Acquire the visible resolution via
VIDIOC_G_SELECTION().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
targetset to
V4L2_SEL_TGT_COMPOSE.
-
-
Returned fields:
-
r.left,r.top,r.width,r.heightthe visible rectangle; it must fit within the frame buffer resolution returned by
VIDIOC_G_FMT()onCAPTURE.
-
-
The following selection targets are supported on
CAPTURE:-
V4L2_SEL_TGT_CROP_BOUNDScorresponds to the coded resolution of the stream.
-
V4L2_SEL_TGT_CROP_DEFAULTthe rectangle covering the part of the
CAPTUREbuffer that contains meaningful picture data (visible area); width and height will be equal to the visible resolution of the stream. -
V4L2_SEL_TGT_CROPthe rectangle within the coded resolution to be output to
CAPTURE; defaults toV4L2_SEL_TGT_CROP_DEFAULT; read-only on hardware without additional compose/scaling capabilities. -
V4L2_SEL_TGT_COMPOSE_BOUNDSthe maximum rectangle within a
CAPTUREbuffer, which the cropped frame can be composed into; equal toV4L2_SEL_TGT_CROPif the hardware does not support compose/scaling. -
V4L2_SEL_TGT_COMPOSE_DEFAULTequal to
V4L2_SEL_TGT_CROP. -
V4L2_SEL_TGT_COMPOSEthe rectangle inside a
CAPTUREbuffer into which the cropped frame is written; defaults toV4L2_SEL_TGT_COMPOSE_DEFAULT; read-only on hardware without additional compose/scaling capabilities. -
V4L2_SEL_TGT_COMPOSE_PADDEDthe rectangle inside a
CAPTUREbuffer which is overwritten by the hardware; equal toV4L2_SEL_TGT_COMPOSEif the hardware does not write padding pixels.
-
-
-
Optional. Enumerate
CAPTUREformats viaVIDIOC_ENUM_FMT()on theCAPTUREqueue. Once the stream information is parsed and known, the client may use this ioctl to discover which raw formats are supported for given stream and select one of them viaVIDIOC_S_FMT(). -
Optional. Set the
CAPTUREformat viaVIDIOC_S_FMT()on theCAPTUREqueue. The client may choose a different format than selected/suggested by the decoder inVIDIOC_G_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
pixelformata raw pixel format.
-
width,heightframe buffer resolution of the decoded stream; typically unchanged from what was returned with
VIDIOC_G_FMT(), but it may be different if the hardware supports composition and/or scaling.
-
-
- Setting the
CAPTUREformat will reset the compose selection rectangles to their default values, based on the new resolution, as described in the previous step.
-
Optional. Set the compose rectangle via
VIDIOC_S_SELECTION()on theCAPTUREqueue if it is desired and if the decoder has compose and/or scaling capabilities.-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
targetset to
V4L2_SEL_TGT_COMPOSE. -
r.left,r.top,r.width,r.heightthe rectangle inside a
CAPTUREbuffer into which the cropped frame is written; defaults toV4L2_SEL_TGT_COMPOSE_DEFAULT; read-only on hardware without additional compose/scaling capabilities.
-
-
Returned fields:
-
r.left,r.top,r.width,r.heightthe visible rectangle; it must fit within the frame buffer resolution returned by
VIDIOC_G_FMT()onCAPTURE.
-
-
-
If all the following conditions are met, the client may resume the decoding instantly:
-
sizeimageof the new format (determined in previous steps) is less than or equal to the size of currently allocated buffers, -
the number of buffers currently allocated is greater than or equal to the minimum number of buffers acquired in previous steps. To fulfill this requirement, the client may use
VIDIOC_CREATE_BUFS()to add new buffers.
In that case, the remaining steps do not apply and the client may resume the decoding by one of the following actions:
-
if the
CAPTUREqueue is streaming, callVIDIOC_DECODER_CMD()with theV4L2_DEC_CMD_STARTcommand, -
if the
CAPTUREqueue is not streaming, callVIDIOC_STREAMON()on theCAPTUREqueue.
However, if the client intends to change the buffer set, to lower memory usage or for any other reasons, it may be achieved by following the steps below.
-
-
If the
CAPTUREqueue is streaming, keep queuing and dequeuing buffers on theCAPTUREqueue until a buffer marked with theV4L2_BUF_FLAG_LASTflag is dequeued. -
If the
CAPTUREqueue is streaming, callVIDIOC_STREAMOFF()on theCAPTUREqueue to stop streaming. -
If the
CAPTUREqueue has buffers allocated, free theCAPTUREbuffers usingVIDIOC_REQBUFS().-
Required fields:
-
countset to 0.
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
memoryfollows standard semantics.
-
-
-
Allocate
CAPTUREbuffers viaVIDIOC_REQBUFS()on theCAPTUREqueue.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
memoryfollows standard semantics.
-
-
Returned fields:
-
countactual number of buffers allocated.
-
Alternatively,
VIDIOC_CREATE_BUFS()on theCAPTUREqueue can be used to have more control over buffer allocation. For example, by allocating buffers larger than the currentCAPTUREformat, future resolution changes can be accommodated.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
memoryfollows standard semantics.
-
formata format representing the maximum framebuffer resolution to be accommodated by newly allocated buffers.
-
-
Returned fields:
-
countadjusted to the number of allocated buffers.
-
-
-
Call
VIDIOC_STREAMON()on theCAPTUREqueue to start decoding frames.
Decoding #
This state is reached after the Capture Setup sequence finishes successfully. In this state, the client queues and dequeues buffers to both queues via VIDIOC_QBUF() and VIDIOC_DQBUF(), following the standard semantics.
The content of the source OUTPUT buffers depends on the active coded pixel format and may be affected by codec-specific extended controls, as stated in the documentation of each format.
Both queues operate independently, following the standard behavior of V4L2 buffer queues and memory-to-memory devices. In addition, the order of decoded frames dequeued from the CAPTURE queue may differ from the order of queuing coded frames to the OUTPUT queue, due to properties of the selected coded format, e.g. frame reordering.
The client must not assume any direct relationship between CAPTURE and OUTPUT buffers and any specific timing of buffers becoming available to dequeue. Specifically:
-
a buffer queued to
OUTPUTmay result in no buffers being produced onCAPTURE(e.g. if it does not contain encoded data, or if only metadata syntax structures are present in it), -
a buffer queued to
OUTPUTmay result in more than one buffer produced onCAPTURE(if the encoded data contained more than one frame, or if returning a decoded frame allowed the decoder to return a frame that preceded it in decode, but succeeded it in the display order), -
a buffer queued to
OUTPUTmay result in a buffer being produced onCAPTURElater into decode process, and/or after processing furtherOUTPUTbuffers, or be returned out of order, e.g. if display reordering is used, -
buffers may become available on the
CAPTUREqueue without additional buffers queued toOUTPUT(e.g. during drain orEOS), because of theOUTPUTbuffers queued in the past whose decoding results are only available at later time, due to specifics of the decoding process.
During the decoding, the decoder may initiate one of the special sequences, as listed below. The sequences will result in the decoder returning all the CAPTURE buffers that originated from all the OUTPUT buffers processed before the sequence started. Last of the buffers will have the V4L2_BUF_FLAG_LAST flag set. To determine the sequence to follow, the client must check if there is any pending event and:
-
if a
V4L2_EVENT_SOURCE_CHANGEevent withchangesset toV4L2_EVENT_SRC_CH_RESOLUTIONis pending, theDynamic Resolution Changesequence needs to be followed, -
if a
V4L2_EVENT_EOSevent is pending, theEnd of Streamsequence needs to be followed.
Some of the sequences can be intermixed with each other and need to be handled as they happen. The exact operation is documented for each sequence.
Should a decoding error occur, it will be reported to the client with the level of details depending on the decoder capabilities. Specifically:
-
the CAPTURE buffer that contains the results of the failed decode operation will be returned with the V4L2_BUF_FLAG_ERROR flag set,
-
if the decoder is able to precisely report the OUTPUT buffer that triggered the error, such buffer will be returned with the V4L2_BUF_FLAG_ERROR flag set.
In case of a fatal failure that does not allow the decoding to continue, any further operations on corresponding decoder file handle will return the -EIO error code. The client may close the file handle and open a new one, or alternatively reinitialize the instance by stopping streaming on both queues, releasing all buffers and performing the Initialization sequence again.
Seek #
Seek is controlled by the OUTPUT queue, as it is the source of coded data. The seek does not require any specific operation on the CAPTURE queue, but it may be affected as per normal decoder operation.
-
Stop the
OUTPUTqueue to begin the seek sequence viaVIDIOC_STREAMOFF().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT.
-
-
The decoder will drop all the pending
OUTPUTbuffers and they must be treated as returned to the client (following standard semantics).
-
-
Restart the
OUTPUTqueue viaVIDIOC_STREAMON().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT.
-
-
The decoder will start accepting new source bytestream buffers after the call returns.
-
-
Start queuing buffers containing coded data after the seek to the
OUTPUTqueue until a suitable resume point is found. -
After a resume point is found, the decoder will start returning
CAPTUREbuffers containing decoded frames.
Dynamic Resolution Change #
Streams that include resolution metadata in the bytestream may require switching to a different resolution during the decoding.
The sequence starts when the decoder detects a coded frame with one or more of the following parameters different from those previously established (and reflected by corresponding queries):
-
coded resolution (
OUTPUTwidth and height), -
visible resolution (selection rectangles),
-
the minimum number of buffers needed for decoding,
-
bit-depth of the bitstream has been changed,
-
colorspace of the bitstream has been changed, but it doesn't require buffer reallocation.
Whenever that happens, the decoder must proceed as follows:
-
After encountering a resolution change in the stream, the decoder sends a
V4L2_EVENT_SOURCE_CHANGEevent withchangesset toV4L2_EVENT_SRC_CH_RESOLUTION. -
The decoder will then process and decode all remaining buffers from before the resolution change point.
- The last buffer from before the change must be marked with the
V4L2_BUF_FLAG_LASTflag, similarly to theDrainsequence above.
- The last buffer from before the change must be marked with the
The client must continue the sequence as described below to continue the decoding process.
-
Dequeue the source change event.
-
Continue with the
Capture Setupsequence.
Drain #
To ensure that all queued OUTPUT buffers have been processed and related CAPTURE buffers are given to the client, the client must follow the drain sequence described below. After the drain sequence ends, the client has received all decoded frames for all OUTPUT buffers queued before the sequence was started.
-
Begin drain by issuing
VIDIOC_DECODER_CMD().-
Required fields:
-
cmdset to
V4L2_DEC_CMD_STOP. -
flagsset to 0.
-
ptsset to 0.
-
-
-
Any
OUTPUTbuffers queued by the client before theVIDIOC_DECODER_CMD()was issued will be processed and decoded as normal. The client must continue to handle both queues independently, similarly to normal decode operation. This includes:-
handling any operations triggered as a result of processing those buffers, such as the
Dynamic Resolution Changesequence, before continuing with the drain sequence, -
queuing and dequeuing
CAPTUREbuffers, until a buffer marked with theV4L2_BUF_FLAG_LASTflag is dequeued, -
dequeuing processed
OUTPUTbuffers, until all the buffers queued before theV4L2_DEC_CMD_STOPcommand are dequeued, -
dequeuing the
V4L2_EVENT_EOSevent, if the client subscribed to it.
-
-
Once all the
OUTPUTbuffers queued before theV4L2_DEC_CMD_STOPcall are dequeued and the lastCAPTUREbuffer is dequeued, the decoder is stopped and it will accept, but not process, any newly queuedOUTPUTbuffers until the client issues any of the following operations:-
V4L2_DEC_CMD_START- the decoder will not be reset and will resume operation normally, with all the state from before the drain, -
a pair of
VIDIOC_STREAMOFF()andVIDIOC_STREAMON()on theCAPTUREqueue - the decoder will resume the operation normally, however anyCAPTUREbuffers still in the queue will be returned to the client, -
a pair of
VIDIOC_STREAMOFF()andVIDIOC_STREAMON()on theOUTPUTqueue - any pending source buffers will be returned to the client and theSeeksequence will be triggered.
-
End of Stream #
If the decoder encounters an end of stream marking in the stream, the decoder will initiate the Drain sequence, which the client must handle as described above, skipping the initial VIDIOC_DECODER_CMD().
Commit Points #
Setting formats and allocating buffers trigger changes in the behavior of the decoder.
-
Setting the format on the
OUTPUTqueue may change the set of formats supported/advertised on theCAPTUREqueue. In particular, it also means that theCAPTUREformat may be reset and the client must not rely on the previously set format being preserved. -
Enumerating formats on the
CAPTUREqueue always returns only formats supported for the currentOUTPUTformat. -
Setting the format on the
CAPTUREqueue does not change the list of formats available on theOUTPUTqueue. An attempt to set aCAPTUREformat that is not supported for the currently selectedOUTPUTformat will result in the decoder adjusting the requestedCAPTUREformat to a supported one. -
Enumerating formats on the
OUTPUTqueue always returns the full set of supported coded formats, irrespectively of the currentCAPTUREformat. -
While buffers are allocated on any of the
OUTPUTorCAPTUREqueues, the client must not change the format on theOUTPUTqueue. Drivers will return the -EBUSY error code for any such format change attempt.
To summarize, setting formats and allocation must always start with the OUTPUT queue and the OUTPUT queue is the master that governs the set of supported formats for the CAPTURE queue.
Memory-to-Memory Stateful Video Encoder Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
A stateful video encoder takes raw video frames in display order and encodes them into a bytestream. It generates complete chunks of the bytestream, including all metadata, headers, etc. The resulting bytestream does not require any further post-processing by the client.
Performing software stream processing, header generation etc. in the driver in order to support this interface is strongly discouraged. In case such operations are needed, use of the Stateless Video Encoder Interface (in development) is strongly advised.
Conventions and Notations Used in This Document #
-
The general V4L2 API rules apply if not specified in this document otherwise.
-
The meaning of words "must", "may", "should", etc. is as per RFC 2119.
-
All steps not marked "optional" are required.
-
VIDIOC_G_EXT_CTRLS()andVIDIOC_S_EXT_CTRLS()may be used interchangeably withVIDIOC_G_CTRL()andVIDIOC_S_CTRL(), unless specified otherwise. -
Single-planar API (see Single- and multi-planar APIs) and applicable structures may be used interchangeably with multi-planar API, unless specified otherwise, depending on encoder capabilities and following the general V4L2 guidelines.
-
i = [a..b]: sequence of integers from a to b, inclusive, i.e. i = [0..2]: i = 0, 1, 2.
-
Given an
OUTPUTbuffer A, then A' represents a buffer on theCAPTUREqueue containing data that resulted from processing buffer A.
Glossary #
Refer to Glossary.
State Machine #
flowchart TB
n0((("Encoding")))
n1(("Initialization"))
n2(("Stopped"))
n3(("Drain"))
n4(("Reset"))
n5(("#160;"))
n5 -->|"open()"| n1
n1 -->|"Both queues streaming"| n0
n0 -->|"V4L2_ENC_CMD_STOP"| n3
n0 -->|"VIDIOC_STREAMOFF(CAPTURE)"| n4
n0 -->|"VIDIOC_STREAMOFF(OUTPUT)"| n2
n0 --> n0
n3 -->|"All CAPTURE<br/>buffers dequeued<br/>or<br/>VIDIOC_STREAMOFF(OUTPUT)"| n2
n3 -->|"VIDIOC_STREAMOFF(CAPTURE)"| n4
n4 -->|"VIDIOC_STREAMON(CAPTURE)"| n0
n4 -->|"VIDIOC_REQBUFS(OUTPUT, 0)"| n1
n2 -->|"V4L2_ENC_CMD_START<br/>or<br/>VIDIOC_STREAMON(OUTPUT)"| n0
n2 -->|"VIDIOC_STREAMOFF(CAPTURE)"| n4
style n5 fill:#333,stroke:#333
Encoder State Machine
Querying Capabilities #
-
To enumerate the set of coded formats supported by the encoder, the client may call
VIDIOC_ENUM_FMT()onCAPTURE.- The full set of supported formats will be returned, regardless of the format set on
OUTPUT.
- The full set of supported formats will be returned, regardless of the format set on
-
To enumerate the set of supported raw formats, the client may call
VIDIOC_ENUM_FMT()onOUTPUT.-
Only the formats supported for the format currently active on
CAPTUREwill be returned. -
In order to enumerate raw formats supported by a given coded format, the client must first set that coded format on
CAPTUREand then enumerate the formats onOUTPUT.
-
-
The client may use
VIDIOC_ENUM_FRAMESIZES()to detect supported resolutions for a given format, passing the desired pixel format inv4l2_frmsizeenumpixel_format.-
Values returned by
VIDIOC_ENUM_FRAMESIZES()for a coded pixel format will include all possible coded resolutions supported by the encoder for the given coded pixel format. -
Values returned by
VIDIOC_ENUM_FRAMESIZES()for a raw pixel format will include all possible frame buffer resolutions supported by the encoder for the given raw pixel format and coded format currently set onCAPTURE.
-
-
The client may use
VIDIOC_ENUM_FRAMEINTERVALS()to detect supported frame intervals for a given format and resolution, passing the desired pixel format inv4l2_frmivalenumpixel_formatand the resolution inv4l2_frmivalenumwidthandv4l2_frmivalenumheight.-
Values returned by
VIDIOC_ENUM_FRAMEINTERVALS()for a coded pixel format and coded resolution will include all possible frame intervals supported by the encoder for the given coded pixel format and resolution. -
Values returned by
VIDIOC_ENUM_FRAMEINTERVALS()for a raw pixel format and resolution will include all possible frame intervals supported by the encoder for the given raw pixel format and resolution and for the coded format, coded resolution and coded frame interval currently set onCAPTURE. -
Support for
VIDIOC_ENUM_FRAMEINTERVALS()is optional. If it is not implemented, then there are no special restrictions other than the limits of the codec itself.
-
-
Supported profiles and levels for the coded format currently set on
CAPTURE, if applicable, may be queried using their respective controls viaVIDIOC_QUERYCTRL(). -
Any additional encoder capabilities may be discovered by querying their respective controls.
Initialization #
-
Set the coded format on the
CAPTUREqueue viaVIDIOC_S_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
pixelformatthe coded format to be produced.
-
sizeimagedesired size of
CAPTUREbuffers; the encoder may adjust it to match hardware requirements. -
width,heightignored (read-only).
-
other fields
follow standard semantics.
-
-
Returned fields:
-
sizeimageadjusted size of
CAPTUREbuffers. -
width,heightthe coded size selected by the encoder based on current state, e.g.
OUTPUTformat, selection rectangles, etc. (read-only).
-
-
-
Optional. Enumerate supported
OUTPUTformats (raw formats for source) for the selected coded format viaVIDIOC_ENUM_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
other fields
follow standard semantics.
-
-
Returned fields:
-
pixelformatraw format supported for the coded format currently selected on the
CAPTUREqueue. -
other fields
follow standard semantics.
-
-
-
Set the raw source format on the
OUTPUTqueue viaVIDIOC_S_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
pixelformatraw format of the source.
-
width,heightsource resolution.
-
other fields
follow standard semantics.
-
-
Returned fields:
-
width,heightmay be adjusted to match encoder minimums, maximums and alignment requirements, as required by the currently selected formats, as reported by
VIDIOC_ENUM_FRAMESIZES(). -
other fields
follow standard semantics.
-
-
Setting the
OUTPUTformat will reset the selection rectangles to their default values, based on the new resolution, as described in the next step.
-
-
Set the raw frame interval on the
OUTPUTqueue viaVIDIOC_S_PARM(). This also sets the coded frame interval on theCAPTUREqueue to the same value.-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
parm.outputset all fields except
parm.output.timeperframeto 0. -
parm.output.timeperframethe desired frame interval; the encoder may adjust it to match hardware requirements.
-
-
Returned fields:
-
parm.output.timeperframethe adjusted frame interval.
-
-
-
Optional Set the coded frame interval on the
CAPTUREqueue viaVIDIOC_S_PARM(). This is only necessary if the coded frame interval is different from the raw frame interval, which is typically the case for off-line encoding. Support for this feature is signalled by the V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL format flag.-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
parm.captureset all fields except
parm.capture.timeperframeto 0. -
parm.capture.timeperframethe desired coded frame interval; the encoder may adjust it to match hardware requirements.
-
-
Returned fields:
-
parm.capture.timeperframethe adjusted frame interval.
-
-
-
Optional. Set the visible resolution for the stream metadata via
VIDIOC_S_SELECTION()on theOUTPUTqueue if it is desired to be different than the full OUTPUT resolution.-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
targetset to
V4L2_SEL_TGT_CROP. -
r.left,r.top,r.width,r.heightvisible rectangle; this must fit within the
V4L2_SEL_TGT_CROP_BOUNDSrectangle and may be subject to adjustment to match codec and hardware constraints.
-
-
Returned fields:
-
r.left,r.top,r.width,r.heightvisible rectangle adjusted by the encoder.
-
-
The following selection targets are supported on
OUTPUT:-
V4L2_SEL_TGT_CROP_BOUNDSequal to the full source frame, matching the active
OUTPUTformat. -
V4L2_SEL_TGT_CROP_DEFAULTequal to
V4L2_SEL_TGT_CROP_BOUNDS. -
V4L2_SEL_TGT_CROPrectangle within the source buffer to be encoded into the
CAPTUREstream; defaults toV4L2_SEL_TGT_CROP_DEFAULT.
-
-
-
Allocate buffers for both
OUTPUTandCAPTUREviaVIDIOC_REQBUFS(). This may be performed in any order.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUTorCAPTURE. -
other fields
follow standard semantics.
-
-
Returned fields:
-
countactual number of buffers allocated.
-
Alternatively,
VIDIOC_CREATE_BUFS()can be used to have more control over buffer allocation.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
other fields
follow standard semantics.
-
-
Returned fields:
-
countadjusted to the number of allocated buffers.
-
-
-
Begin streaming on both
OUTPUTandCAPTUREqueues viaVIDIOC_STREAMON(). This may be performed in any order. The actual encoding process starts when both queues start streaming.
Encoding #
This state is reached after the Initialization sequence finishes successfully. In this state, the client queues and dequeues buffers to both queues via VIDIOC_QBUF() and VIDIOC_DQBUF(), following the standard semantics.
The content of encoded CAPTURE buffers depends on the active coded pixel format and may be affected by codec-specific extended controls, as stated in the documentation of each format.
Both queues operate independently, following standard behavior of V4L2 buffer queues and memory-to-memory devices. In addition, the order of encoded frames dequeued from the CAPTURE queue may differ from the order of queuing raw frames to the OUTPUT queue, due to properties of the selected coded format, e.g. frame reordering.
The client must not assume any direct relationship between CAPTURE and OUTPUT buffers and any specific timing of buffers becoming available to dequeue. Specifically:
-
a buffer queued to
OUTPUTmay result in more than one buffer produced onCAPTURE(for example, if returning an encoded frame allowed the encoder to return a frame that preceded it in display, but succeeded it in the decode order; however, there may be other reasons for this as well), -
a buffer queued to
OUTPUTmay result in a buffer being produced onCAPTURElater into encode process, and/or after processing furtherOUTPUTbuffers, or be returned out of order, e.g. if display reordering is used, -
buffers may become available on the
CAPTUREqueue without additional buffers queued toOUTPUT(e.g. during drain orEOS), because of theOUTPUTbuffers queued in the past whose encoding results are only available at later time, due to specifics of the encoding process, -
buffers queued to
OUTPUTmay not become available to dequeue instantly after being encoded into a correspondingCAPTUREbuffer, e.g. if the encoder needs to use the frame as a reference for encoding further frames.
Should an encoding error occur, it will be reported to the client with the level of details depending on the encoder capabilities. Specifically:
-
the
CAPTUREbuffer (if any) that contains the results of the failed encode operation will be returned with theV4L2_BUF_FLAG_ERRORflag set, -
if the encoder is able to precisely report the
OUTPUTbuffer(s) that triggered the error, such buffer(s) will be returned with theV4L2_BUF_FLAG_ERRORflag set.
In case of a fatal failure that does not allow the encoding to continue, any further operations on corresponding encoder file handle will return the -EIO error code. The client may close the file handle and open a new one, or alternatively reinitialize the instance by stopping streaming on both queues, releasing all buffers and performing the Initialization sequence again.
Encoding Parameter Changes #
The client is allowed to use VIDIOC_S_CTRL() to change encoder parameters at any time. The availability of parameters is encoder-specific and the client must query the encoder to find the set of available controls.
The ability to change each parameter during encoding is encoder-specific, as per the standard semantics of the V4L2 control interface. The client may attempt to set a control during encoding and if the operation fails with the -EBUSY error code, the CAPTURE queue needs to be stopped for the configuration change to be allowed. To do this, it may follow the Drain sequence to avoid losing the already queued/encoded frames.
The timing of parameter updates is encoder-specific, as per the standard semantics of the V4L2 control interface. If the client needs to apply the parameters exactly at specific frame, using the Request API (Request API) should be considered, if supported by the encoder.
Drain #
To ensure that all the queued OUTPUT buffers have been processed and the related CAPTURE buffers are given to the client, the client must follow the drain sequence described below. After the drain sequence ends, the client has received all encoded frames for all OUTPUT buffers queued before the sequence was started.
-
Begin the drain sequence by issuing
VIDIOC_ENCODER_CMD().-
Required fields:
-
cmdset to
V4L2_ENC_CMD_STOP. -
flagsset to 0.
-
ptsset to 0.
-
-
-
Any
OUTPUTbuffers queued by the client before theVIDIOC_ENCODER_CMD()was issued will be processed and encoded as normal. The client must continue to handle both queues independently, similarly to normal encode operation. This includes:-
queuing and dequeuing
CAPTUREbuffers, until a buffer marked with theV4L2_BUF_FLAG_LASTflag is dequeued, -
dequeuing processed
OUTPUTbuffers, until all the buffers queued before theV4L2_ENC_CMD_STOPcommand are dequeued, -
dequeuing the
V4L2_EVENT_EOSevent, if the client subscribes to it.
-
-
Once all
OUTPUTbuffers queued before theV4L2_ENC_CMD_STOPcall are dequeued and the lastCAPTUREbuffer is dequeued, the encoder is stopped and it will accept, but not process any newly queuedOUTPUTbuffers until the client issues any of the following operations:-
V4L2_ENC_CMD_START- the encoder will not be reset and will resume operation normally, with all the state from before the drain, -
a pair of
VIDIOC_STREAMOFF()andVIDIOC_STREAMON()on theCAPTUREqueue - the encoder will be reset (see theResetsequence) and then resume encoding, -
a pair of
VIDIOC_STREAMOFF()andVIDIOC_STREAMON()on theOUTPUTqueue - the encoder will resume operation normally, however any source frames queued to theOUTPUTqueue betweenV4L2_ENC_CMD_STOPandVIDIOC_STREAMOFF()will be discarded.
-
Reset #
The client may want to request the encoder to reinitialize the encoding, so that the following stream data becomes independent from the stream data generated before. Depending on the coded format, that may imply that:
-
encoded frames produced after the restart must not reference any frames produced before the stop, e.g. no long term references for H.264/HEVC,
-
any headers that must be included in a standalone stream must be produced again, e.g. SPS and PPS for H.264/HEVC.
This can be achieved by performing the reset sequence.
-
Perform the
Drainsequence to ensure all the in-flight encoding finishes and respective buffers are dequeued. -
Stop streaming on the
CAPTUREqueue viaVIDIOC_STREAMOFF(). This will return all currently queuedCAPTUREbuffers to the client, without valid frame data. -
Start streaming on the
CAPTUREqueue viaVIDIOC_STREAMON()and continue with regular encoding sequence. The encoded frames produced intoCAPTUREbuffers from now on will contain a standalone stream that can be decoded without the need for frames encoded before the reset sequence, starting at the firstOUTPUTbuffer queued after issuing theV4L2_ENC_CMD_STOPof theDrainsequence.
This sequence may be also used to change encoding parameters for encoders without the ability to change the parameters on the fly.
Commit Points #
Setting formats and allocating buffers triggers changes in the behavior of the encoder.
-
Setting the format on the
CAPTUREqueue may change the set of formats supported/advertised on theOUTPUTqueue. In particular, it also means that theOUTPUTformat may be reset and the client must not rely on the previously set format being preserved. -
Enumerating formats on the
OUTPUTqueue always returns only formats supported for the currentCAPTUREformat. -
Setting the format on the
OUTPUTqueue does not change the list of formats available on theCAPTUREqueue. An attempt to set theOUTPUTformat that is not supported for the currently selectedCAPTUREformat will result in the encoder adjusting the requestedOUTPUTformat to a supported one. -
Enumerating formats on the
CAPTUREqueue always returns the full set of supported coded formats, irrespective of the currentOUTPUTformat. -
While buffers are allocated on any of the
OUTPUTorCAPTUREqueues, the client must not change the format on theCAPTUREqueue. Drivers will return the -EBUSY error code for any such format change attempt.
To summarize, setting formats and allocation must always start with the CAPTURE queue and the CAPTURE queue is the master that governs the set of supported formats for the OUTPUT queue.
Event Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The V4L2 event interface provides a means for a user to get immediately notified on certain conditions taking place on a device. This might include start of frame or loss of signal events, for example. Changes in the value or state of a V4L2 control can also be reported through events.
To receive events, the events the user is interested in first must be subscribed using the ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT ioctl. Once an event is subscribed, the events of subscribed types are dequeueable using the ioctl VIDIOC_DQEVENT ioctl. Events may be unsubscribed using VIDIOC_UNSUBSCRIBE_EVENT ioctl. The special event type V4L2_EVENT_ALL may be used to unsubscribe all the events the driver supports.
The event subscriptions and event queues are specific to file handles. Subscribing an event on one file handle does not affect other file handles.
The information on dequeueable events is obtained by using select or poll system calls on video devices. The V4L2 events use POLLPRI events on poll system call and exceptions on select system call.
Starting with kernel 3.1 certain guarantees can be given with regards to events:
-
Each subscribed event has its own internal dedicated event queue. This means that flooding of one event type will not interfere with other event types.
-
If the internal event queue for a particular subscribed event becomes full, then the oldest event in that queue will be dropped.
-
Where applicable, certain event types can ensure that the payload of the oldest event that is about to be dropped will be merged with the payload of the next oldest event. Thus ensuring that no information is lost, but only an intermediate step leading up to that information. See the documentation for the event you want to subscribe to whether this is applicable for that event or not.
Video Memory-To-Memory Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
A V4L2 memory-to-memory device can compress, decompress, transform, or otherwise convert video data from one format into another format, in memory. Such memory-to-memory devices set the V4L2_CAP_VIDEO_M2M or V4L2_CAP_VIDEO_M2M_MPLANE capability. Examples of memory-to-memory devices are codecs, scalers, deinterlacers or format converters (i.e. converting from YUV to RGB).
A memory-to-memory video node acts just like a normal video node, but it supports both output (sending frames from memory to the hardware) and capture (receiving the processed frames from the hardware into memory) stream I/O. An application will have to setup the stream I/O for both sides and finally call VIDIOC_STREAMON for both capture and output to start the hardware.
Memory-to-memory devices function as a shared resource: you can open the video node multiple times, each application setting up their own properties that are local to the file handle, and each can use it independently from the others. The driver will arbitrate access to the hardware and reprogram it whenever another file handler gets access. This is different from the usual video node behavior where the video properties are global to the device (i.e. changing something through one file handle is visible through another file handle).
One of the most common memory-to-memory device is the codec. Codecs are more complicated than most and require additional setup for their codec parameters. This is done through codec controls. See codec-controls. More details on how to use codec memory-to-memory devices are given in the following sections.
Metadata Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Metadata refers to any non-image data that supplements video frames with additional information. This may include statistics computed over the image, frame capture parameters supplied by the image source or device specific parameters for specifying how the device processes images. This interface is intended for transfer of metadata between the userspace and the hardware and control of that operation.
The metadata interface is implemented on video device nodes. The device can be dedicated to metadata or can support both video and metadata as specified in its reported capabilities.
Querying Capabilities #
Device nodes supporting the metadata capture interface set the V4L2_CAP_META_CAPTURE flag in the device_caps field of the v4l2_capability structure returned by the VIDIOC_QUERYCAP() ioctl. That flag means the device can capture metadata to memory. Similarly, device nodes supporting metadata output interface set the V4L2_CAP_META_OUTPUT flag in the device_caps field of v4l2_capability structure. That flag means the device can read metadata from memory.
At least one of the read/write or streaming I/O methods must be supported.
Data Format Negotiation #
The metadata device uses the Data Formats ioctls to select the capture format. The metadata buffer content format is bound to that selected format. In addition to the basic Data Formats ioctls, the VIDIOC_ENUM_FMT() ioctl must be supported as well.
To use the Data Formats ioctls applications set the type field of the v4l2_format structure to V4L2_BUF_TYPE_META_CAPTURE or to V4L2_BUF_TYPE_META_OUTPUT and use the v4l2_meta_format meta member of the fmt union as needed per the desired operation. Both drivers and applications must set the remainder of the v4l2_format structure to 0.
Devices that capture metadata by line have the struct v4l2_fmtdesc V4L2_FMT_FLAG_META_LINE_BASED flag set for VIDIOC_ENUM_FMT(). Such devices can typically also capture image data. This primarily involves devices that receive the data from a different devices such as a camera sensor.
v4l2_meta_format
|
__u32 |
|
The data format, set by the application. This is a little endian four character code. V4L2 defines metadata formats in Metadata Formats. |
|
__u32 |
|
Maximum buffer size in bytes required for data. The value is set by the driver. |
|
__u32 |
|
Width of a line of metadata in Data Units. Valid when :c:type`v4l2_fmtdesc` flag |
|
__u32 |
|
Number of rows of metadata. Valid when :c:type`v4l2_fmtdesc` flag |
|
__u32 |
|
Offset in bytes between the beginning of two consecutive lines. Valid when :c:type`v4l2_fmtdesc` flag |
Video Output Overlay Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Also known as On-Screen Display (OSD)
Some video output devices can overlay a framebuffer image onto the outgoing video signal. Applications can set up such an overlay using this interface, which borrows structures and ioctls of the Video Overlay interface.
The OSD function is accessible through the same character special file as the Video Output function.
Querying Capabilities #
Devices supporting the Video Output Overlay interface set the V4L2_CAP_VIDEO_OUTPUT_OVERLAY flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl.
Framebuffer #
Contrary to the Video Overlay interface the framebuffer is normally implemented on the TV card and not the graphics card. On Linux it is accessible as a framebuffer device (/dev/fbN). Given a V4L2 device, applications can find the corresponding framebuffer device by calling the VIDIOC_G_FBUF ioctl. It returns, amongst other information, the physical address of the framebuffer in the base field of struct v4l2_framebuffer. The framebuffer device ioctl FBIOGET_FSCREENINFO returns the same address in the smem_start field of struct fb_fix_screeninfo. The FBIOGET_FSCREENINFO ioctl and struct fb_fix_screeninfo are defined in the linux/fb.h header file.
The width and height of the framebuffer depends on the current video standard. A V4L2 driver may reject attempts to change the video standard (or any other ioctl which would imply a framebuffer size change) with an EBUSY error code until all applications closed the framebuffer device.
Example: Finding a framebuffer device for OSD #
struct v4l2_framebuffer fbuf;
unsigned int i;
int fb_fd;
if
for
/* fb_fd is the file descriptor of the framebuffer device
for the video output overlay, or -1 if no device was found. */
Overlay Window and Scaling #
The overlay is controlled by source and target rectangles. The source rectangle selects a subsection of the framebuffer image to be overlaid, the target rectangle an area in the outgoing video signal where the image will appear. Drivers may or may not support scaling, and arbitrary sizes and positions of these rectangles. Further drivers may support any (or none) of the clipping/blending methods defined for the Video Overlay interface.
A struct v4l2_window defines the size of the source rectangle, its position in the framebuffer and the clipping/blending method to be used for the overlay. To get the current parameters applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY and call the VIDIOC_G_FMT ioctl. The driver fills the struct v4l2_window substructure named win. It is not possible to retrieve a previously programmed clipping list or bitmap.
To program the source rectangle applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY, initialize the win substructure and call the VIDIOC_S_FMT ioctl. The driver adjusts the parameters against hardware limits and returns the actual parameters as VIDIOC_G_FMT does. Like VIDIOC_S_FMT, the VIDIOC_TRY_FMT ioctl can be used to learn about driver capabilities without actually changing driver state. Unlike VIDIOC_S_FMT this also works after the overlay has been enabled.
A struct v4l2_crop defines the size and position of the target rectangle. The scaling factor of the overlay is implied by the width and height given in struct v4l2_window and struct v4l2_crop. The cropping API applies to Video Output and Video Output Overlay devices in the same way as to Video Capture and Video Overlay devices, merely reversing the direction of the data flow. For more information see Image Cropping, Insertion and Scaling -- the CROP API.
Enabling Overlay #
There is no V4L2 ioctl to enable or disable the overlay, however the framebuffer interface of the driver may support the FBIOBLANK ioctl.
Video Output Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Video output devices encode stills or image sequences as analog video signal. With this interface applications can control the encoding process and move images from user space to the driver.
Conventionally V4L2 video output devices are accessed through character device special files named /dev/video and /dev/video0 to /dev/video63 with major number 81 and minor numbers 0 to 63. /dev/video is typically a symbolic link to the preferred video device.
Querying Capabilities #
Devices supporting the video output interface set the V4L2_CAP_VIDEO_OUTPUT or V4L2_CAP_VIDEO_OUTPUT_MPLANE flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. As secondary device functions they may also support the raw VBI output (V4L2_CAP_VBI_OUTPUT) interface. At least one of the read/write or streaming I/O methods must be supported. Modulators and audio outputs are optional.
Supplemental Functions #
Video output devices shall support audio output, modulator, controls, cropping and scaling and streaming parameter ioctls as needed. The video output ioctls must be supported by all video output devices.
Image Format Negotiation #
The output is determined by cropping and image format parameters. The former select an area of the video picture where the image will appear, the latter how images are stored in memory, i. e. in RGB or YUV format, the number of bits per pixel or width and height. Together they also define how images are scaled in the process.
As usual these parameters are not reset at open() time to permit Unix tool chains, programming a device and then writing to it as if it was a plain file. Well written V4L2 applications ensure they really get what they want, including cropping and scaling.
Cropping initialization at minimum requires to reset the parameters to defaults. An example is given in Image Cropping, Insertion and Scaling -- the CROP API.
To query the current image format applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VIDEO_OUTPUT or V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE and call the VIDIOC_G_FMT ioctl with a pointer to this structure. Drivers fill the struct v4l2_pix_format pix or the struct v4l2_pix_format_mplane pix_mp member of the fmt union.
To request different parameters applications set the type field of a struct v4l2_format as above and initialize all fields of the struct v4l2_pix_format vbi member of the fmt union, or better just modify the results of VIDIOC_G_FMT, and call the VIDIOC_S_FMT ioctl with a pointer to this structure. Drivers may adjust the parameters and finally return the actual parameters as VIDIOC_G_FMT does.
Like VIDIOC_S_FMT the VIDIOC_TRY_FMT ioctl can be used to learn about hardware limitations without disabling I/O or possibly time consuming hardware preparations.
The contents of struct v4l2_pix_format and struct v4l2_pix_format_mplane are discussed in Image Formats. See also the specification of the VIDIOC_G_FMT, VIDIOC_S_FMT and VIDIOC_TRY_FMT ioctls for details. Video output devices must implement both the VIDIOC_G_FMT and VIDIOC_S_FMT ioctl, even if VIDIOC_S_FMT ignores all requests and always returns default parameters as VIDIOC_G_FMT does. VIDIOC_TRY_FMT is optional.
Writing Images #
A video output device may support the write() function and/or streaming (memory mapping or user pointer) I/O. See Input/Output for details.
Video Overlay Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Also known as Framebuffer Overlay or Previewing.
Video overlay devices have the ability to genlock (TV-)video into the (VGA-)video signal of a graphics card, or to store captured images directly in video memory of a graphics card, typically with clipping. This can be considerable more efficient than capturing images and displaying them by other means. In the old days when only nuclear power plants needed cooling towers this used to be the only way to put live video into a window.
Video overlay devices are accessed through the same character special files as video capture devices.
The driver may support simultaneous overlay and capturing using the read/write and streaming I/O methods. If so, operation at the nominal frame rate of the video standard is not guaranteed. Frames may be directed away from overlay to capture, or one field may be used for overlay and the other for capture if the capture parameters permit this.
Applications should use different file descriptors for capturing and overlay. This must be supported by all drivers capable of simultaneous capturing and overlay. Optionally these drivers may also permit capturing and overlay with a single file descriptor for compatibility with V4L and earlier versions of V4L2. 1
A common application of two file descriptors is the X11 Xv/V4L interface driver and a V4L2 application. While the X server controls video overlay, the application can take advantage of memory mapping and DMA.
Querying Capabilities #
Devices supporting the video overlay interface set the V4L2_CAP_VIDEO_OVERLAY flag in the capabilities field of struct v4l2_capability returned by the vidioc_querycap ioctl. The overlay I/O method specified below must be supported. Tuners and audio inputs are optional.
Supplemental Functions #
Video overlay devices shall support audio input, tuner, controls, cropping and scaling and streaming parameter ioctls as needed. The video input and video standard ioctls must be supported by all video overlay devices.
Setup #
Note: support for this has been removed. Before overlay can commence applications must program the driver with frame buffer parameters, namely the address and size of the frame buffer and the image format, for example RGB 5:6:5. The VIDIOC_G_FBUF and VIDIOC_S_FBUF ioctls are available to get and set these parameters, respectively. The VIDIOC_S_FBUF ioctl is privileged because it allows to set up DMA into physical memory, bypassing the memory protection mechanisms of the kernel. Only the superuser can change the frame buffer address and size. Users are not supposed to run TV applications as root or with SUID bit set. A small helper application with suitable privileges should query the graphics system and program the V4L2 driver at the appropriate time.
Some devices add the video overlay to the output signal of the graphics card. In this case the frame buffer is not modified by the video device, and the frame buffer address and pixel format are not needed by the driver. The VIDIOC_S_FBUF ioctl is not privileged. An application can check for this type of device by calling the VIDIOC_G_FBUF ioctl.
A driver may support any (or none) of five clipping/blending methods:
-
Chroma-keying displays the overlaid image only where pixels in the primary graphics surface assume a certain color.
-
Note: support for this has been removed. A bitmap can be specified where each bit corresponds to a pixel in the overlaid image. When the bit is set, the corresponding video pixel is displayed, otherwise a pixel of the graphics surface.
-
Note: support for this has been removed. A list of clipping rectangles can be specified. In these regions no video is displayed, so the graphics surface can be seen here.
-
The framebuffer has an alpha channel that can be used to clip or blend the framebuffer with the video.
-
A global alpha value can be specified to blend the framebuffer contents with video images.
When simultaneous capturing and overlay is supported and the hardware prohibits different image and frame buffer formats, the format requested first takes precedence. The attempt to capture (VIDIOC_S_FMT) or overlay (VIDIOC_S_FBUF) may fail with an EBUSY error code or return accordingly modified parameters..
Overlay Window #
The overlaid image is determined by cropping and overlay window parameters. The former select an area of the video picture to capture, the latter how images are overlaid and clipped. Cropping initialization at minimum requires to reset the parameters to defaults. An example is given in crop.
The overlay window is described by a struct v4l2_window. It defines the size of the image, its position over the graphics surface and the clipping to be applied. To get the current parameters applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VIDEO_OVERLAY and call the VIDIOC_G_FMT ioctl. The driver fills the struct v4l2_window substructure named win. It is not possible to retrieve a previously programmed clipping list or bitmap.
To program the overlay window applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VIDEO_OVERLAY, initialize the win substructure and call the VIDIOC_S_FMT ioctl. The driver adjusts the parameters against hardware limits and returns the actual parameters as VIDIOC_G_FMT does. Like VIDIOC_S_FMT, the VIDIOC_TRY_FMT ioctl can be used to learn about driver capabilities without actually changing driver state. Unlike VIDIOC_S_FMT this also works after the overlay has been enabled.
The scaling factor of the overlaid image is implied by the width and height given in struct v4l2_window and the size of the cropping rectangle. For more information see crop.
When simultaneous capturing and overlay is supported and the hardware prohibits different image and window sizes, the size requested first takes precedence. The attempt to capture or overlay as well (VIDIOC_S_FMT) may fail with an EBUSY error code or return accordingly modified parameters.
v4l2_window
struct v4l2_window #
-
struct v4l2_rect wSize and position of the window relative to the top, left corner of the frame buffer defined with VIDIOC_S_FBUF. The window can extend the frame buffer width and height, the
xandycoordinates can be negative, and it can lie completely outside the frame buffer. The driver clips the window accordingly, or if that is not possible, modifies its size and/or position. -
enum v4l2_field fieldApplications set this field to determine which video field shall be overlaid, typically one of
V4L2_FIELD_ANY(0),V4L2_FIELD_TOP,V4L2_FIELD_BOTTOMorV4L2_FIELD_INTERLACED. Drivers may have to choose a different field order and return the actual setting here. -
__u32 chromakeyWhen chroma-keying has been negotiated with VIDIOC_S_FBUF applications set this field to the desired pixel value for the chroma key. The format is the same as the pixel format of the framebuffer (struct
v4l2_framebufferfmt.pixelformatfield), with bytes in host order. E. g. for V4L2_PIX_FMT_BGR24 the value should be 0xRRGGBB on a little endian, 0xBBGGRR on a big endian host. -
struct v4l2_clip * clipsNote: support for this has been removed. When chroma-keying has not been negotiated and VIDIOC_G_FBUF indicated this capability, applications can set this field to point to an array of clipping rectangles.
Like the window coordinates w, clipping rectangles are defined relative to the top, left corner of the frame buffer. However clipping rectangles must not extend the frame buffer width and height, and they must not overlap. If possible applications should merge adjacent rectangles. Whether this must create x-y or y-x bands, or the order of rectangles, is not defined. When clip lists are not supported the driver ignores this field. Its contents after calling VIDIOC_S_FMT are undefined.
-
__u32 clipcountNote: support for this has been removed. When the application set the
clipsfield, this field must contain the number of clipping rectangles in the list. When clip lists are not supported the driver ignores this field, its contents after calling VIDIOC_S_FMT are undefined. When clip lists are supported but no clipping is desired this field must be set to zero. -
void * bitmapNote: support for this has been removed. When chroma-keying has not been negotiated and VIDIOC_G_FBUF indicated this capability, applications can set this field to point to a clipping bit mask.
It must be of the same size as the window, w.width and w.height. Each bit corresponds to a pixel in the overlaid image, which is displayed only when the bit is set. Pixel coordinates translate to bits like:
&
where 0 ≤ x < w.width and 0 ≤ y <w.height. 2
When a clipping bit mask is not supported the driver ignores this field, its contents after calling VIDIOC_S_FMT are undefined. When a bit mask is supported but no clipping is desired this field must be set to NULL.
Applications need not create a clip list or bit mask. When they pass both, or despite negotiating chroma-keying, the results are undefined. Regardless of the chosen method, the clipping abilities of the hardware may be limited in quantity or quality. The results when these limits are exceeded are undefined. 3
-
__u8 global_alphaThe global alpha value used to blend the framebuffer with video images, if global alpha blending has been negotiated (
V4L2_FBUF_FLAG_GLOBAL_ALPHA, see VIDIOC_S_FBUF, framebuffer-flags).
v4l2_clip
struct v4l2_clip 4 #
-
struct v4l2_rect cCoordinates of the clipping rectangle, relative to the top, left corner of the frame buffer. Only window pixels outside all clipping rectangles are displayed.
-
struct v4l2_clip * nextPointer to the next clipping rectangle,
NULLwhen this is the last rectangle. Drivers ignore this field, it cannot be used to pass a linked list of clipping rectangles.
v4l2_rect
struct v4l2_rect #
-
__s32 leftHorizontal offset of the top, left corner of the rectangle, in pixels.
-
__s32 topVertical offset of the top, left corner of the rectangle, in pixels. Offsets increase to the right and down.
-
__u32 widthWidth of the rectangle, in pixels.
-
__u32 heightHeight of the rectangle, in pixels.
Enabling Overlay #
To start or stop the frame buffer overlay applications call the vidioc_overlay ioctl.
[1] In the opinion of the designers of this API, no driver writer taking the efforts to support simultaneous capturing and overlay will restrict this ability by requiring a single file descriptor, as in V4L and earlier versions of V4L2. Making this optional means applications depending on two file descriptors need backup routines to be compatible with all drivers, which is considerable more work than using two fds in applications which do not. Also two fd's fit the general concept of one file descriptor for each logical stream. Hence as a complexity trade-off drivers must support two file descriptors and may support single fd operation.
[2] Should we require w.width to be a multiple of eight?
[3] When the image is written into frame buffer memory it will be undesirable if the driver clips out less pixels than expected, because the application and graphics system are not aware these regions need to be refreshed. The driver should clip out more pixels or not write the image at all.
[4] The X Window system defines "regions" which are vectors of struct BoxRec { short x1, y1, x2, y2; } with width = x2 - x1 and height = y2 - y1, so one cannot pass X11 clip lists directly.
Radio Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
This interface is intended for AM and FM (analog) radio receivers and transmitters.
Conventionally V4L2 radio devices are accessed through character device special files named /dev/radio and /dev/radio0 to /dev/radio63 with major number 81 and minor numbers 64 to 127.
Querying Capabilities #
Devices supporting the radio interface set the V4L2_CAP_RADIO and V4L2_CAP_TUNER or V4L2_CAP_MODULATOR flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. Other combinations of capability flags are reserved for future extensions.
Supplemental Functions #
Radio devices can support controls, and must support the tuner or modulator ioctls.
They do not support the video input or output, audio input or output, video standard, cropping and scaling, compression and streaming parameter, or overlay ioctls. All other ioctls and I/O methods are reserved for future extensions.
Programming #
Radio devices may have a couple audio controls (as discussed in User Controls) such as a volume control, possibly custom controls. Further all radio devices have one tuner or modulator (these are discussed in Tuners and Modulators) with index number zero to select the radio frequency and to determine if a monaural or FM stereo program is received/emitted. Drivers switch automatically between AM and FM depending on the selected frequency. The VIDIOC_G_TUNER or VIDIOC_G_MODULATOR ioctl reports the supported frequency range.
Raw VBI Data Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
VBI is an abbreviation of Vertical Blanking Interval, a gap in the sequence of lines of an analog video signal. During VBI no picture information is transmitted, allowing some time while the electron beam of a cathode ray tube TV returns to the top of the screen. Using an oscilloscope you will find here the vertical synchronization pulses and short data packages ASK modulated 1 onto the video signal. These are transmissions of services such as Teletext or Closed Caption.
Subject of this interface type is raw VBI data, as sampled off a video signal, or to be added to a signal for output. The data format is similar to uncompressed video images, a number of lines times a number of samples per line, we call this a VBI image.
Conventionally V4L2 VBI devices are accessed through character device special files named /dev/vbi and /dev/vbi0 to /dev/vbi31 with major number 81 and minor numbers 224 to 255. /dev/vbi is typically a symbolic link to the preferred VBI device. This convention applies to both input and output devices.
To address the problems of finding related video and VBI devices VBI capturing and output is also available as device function under /dev/video. To capture or output raw VBI data with these devices applications must call the VIDIOC_S_FMT ioctl. Accessed as /dev/vbi, raw VBI capturing or output is the default device function.
Querying Capabilities #
Devices supporting the raw VBI capturing or output API set the V4L2_CAP_VBI_CAPTURE or V4L2_CAP_VBI_OUTPUT flags, respectively, in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. At least one of the read/write or streaming I/O methods must be supported. VBI devices may or may not have a tuner or modulator.
Supplemental Functions #
VBI devices shall support video input or output, tuner or modulator, and controls ioctls as needed. The video standard ioctls provide information vital to program a VBI device, therefore must be supported.
Raw VBI Format Negotiation #
Raw VBI sampling abilities can vary, in particular the sampling frequency. To properly interpret the data V4L2 specifies an ioctl to query the sampling parameters. Moreover, to allow for some flexibility applications can also suggest different parameters.
As usual these parameters are not reset at open() time to permit Unix tool chains, programming a device and then reading from it as if it was a plain file. Well written V4L2 applications should always ensure they really get what they want, requesting reasonable parameters and then checking if the actual parameters are suitable.
To query the current raw VBI capture parameters applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_VBI_CAPTURE or V4L2_BUF_TYPE_VBI_OUTPUT, and call the VIDIOC_G_FMT ioctl with a pointer to this structure. Drivers fill the struct v4l2_vbi_format vbi member of the fmt union.
To request different parameters applications set the type field of a struct v4l2_format as above and initialize all fields of the struct v4l2_vbi_format vbi member of the fmt union, or better just modify the results of VIDIOC_G_FMT, and call the VIDIOC_S_FMT ioctl with a pointer to this structure. Drivers return an EINVAL error code only when the given parameters are ambiguous, otherwise they modify the parameters according to the hardware capabilities and return the actual parameters. When the driver allocates resources at this point, it may return an EBUSY error code to indicate the returned parameters are valid but the required resources are currently not available. That may happen for instance when the video and VBI areas to capture would overlap, or when the driver supports multiple opens and another process already requested VBI capturing or output. Anyway, applications must expect other resource allocation points which may return EBUSY, at the ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF ioctl and the first read() , write() and select() calls.
VBI devices must implement both the VIDIOC_G_FMT and VIDIOC_S_FMT ioctl, even if VIDIOC_S_FMT ignores all requests and always returns default parameters as VIDIOC_G_FMT does. VIDIOC_TRY_FMT is optional.
v4l2_vbi_format
|
__u32 |
|
Samples per second, i. e. unit 1 Hz. |
|
__u32 |
|
Horizontal offset of the VBI image, relative to the leading edge of the line synchronization pulse and counted in samples: The first sample in the VBI image will be located |
|
__u32 |
|
|
|
__u32 |
|
Defines the sample format as in Image Formats, a four-character-code. 2 Usually this is |
|
__u32 |
|
This is the scanning system line number associated with the first line of the VBI image, of the first and the second field respectively. See vbi-525 and vbi-625 for valid values. The |
|
__u32 |
|
The number of lines in the first and second field image, respectively. |
|
Drivers should be as flexibility as possible. For example, it may be possible to extend or move the VBI capture window down to the picture area, implementing a 'full field mode' to capture data service transmissions embedded in the picture. An application can set the first or second Both To initialize the |
||
|
__u32 |
|
See vbifmt-flags below. Currently only drivers set flags, applications must set this field to zero. |
|
__u32 |
|
This array is reserved for future extensions. Drivers and applications must set it to zero. |
|
|
0x0001 |
This flag indicates hardware which does not properly distinguish between fields. Normally the VBI image stores the first field (lower scanning line numbers) first in memory. This may be a top or bottom field depending on the video standard. When this flag is set the first or second field may be stored first, however the fields are still in correct temporal order with the older field first in memory. 3 |
|
|
0x0002 |
By default the two field images will be passed sequentially; all lines of the first field followed by all lines of the second field (compare Field Order |
Line synchronization
ITU-R 525 line numbering (M/NTSC and M/PAL)
ITU-R 625 line numbering
Remember the VBI image format depends on the selected video standard, therefore the application must choose a new standard or query the current standard first. Attempts to read or write data ahead of format negotiation, or after switching the video standard which may invalidate the negotiated VBI parameters, should be refused by the driver. A format change during active I/O is not permitted.
Reading and writing VBI images #
To assure synchronization with the field number and easier implementation, the smallest unit of data passed at a time is one frame, consisting of two fields of VBI images immediately following in memory.
The total size of a frame computes as follows:
* samples_per_line * sample size in bytes
The sample size is most likely always one byte, applications must check the sample_format field though, to function properly with other drivers.
A VBI device may support read/write and/or streaming (memory mapping or user pointer) I/O. The latter bears the possibility of synchronizing video and VBI data by using buffer timestamps.
Remember the VIDIOC_STREAMON ioctl and the first read(), write() and select() call can be resource allocation points returning an EBUSY error code if the required hardware resources are temporarily unavailable, for example the device is already in use by another process.
[1] ASK: Amplitude-Shift Keying. A high signal level represents a '1' bit, a low level a '0' bit.
[2] A few devices may be unable to sample VBI data at all but can extend the video capture window to the VBI region.
[3] Most VBI services transmit on both fields, but some have different semantics depending on the field number. These cannot be reliable decoded or encoded when V4L2_VBI_UNSYNC is set.
RDS Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Radio Data System transmits supplementary information in binary format, for example the station name or travel information, on an inaudible audio subcarrier of a radio program. This interface is aimed at devices capable of receiving and/or transmitting RDS information.
For more information see the core RDS standard IEC 62106 and the RBDS standard NRSC-4-B.
The RBDS standard also specifies support for MMBS (Modified Mobile Search). This is a proprietary format which seems to be discontinued. The RDS interface does not support this format. Should support for MMBS (or the so-called 'E blocks' in general) be needed, then please contact the linux-media mailing list: https://linuxtv.org/lists.php.
Querying Capabilities #
Devices supporting the RDS capturing API set the V4L2_CAP_RDS_CAPTURE flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. Any tuner that supports RDS will set the V4L2_TUNER_CAP_RDS flag in the capability field of struct v4l2_tuner. If the driver only passes RDS blocks without interpreting the data the V4L2_TUNER_CAP_RDS_BLOCK_IO flag has to be set, see Reading RDS data. For future use the flag V4L2_TUNER_CAP_RDS_CONTROLS has also been defined. However, a driver for a radio tuner with this capability does not yet exist, so if you are planning to write such a driver you should discuss this on the linux-media mailing list: https://linuxtv.org/lists.php.
Whether an RDS signal is present can be detected by looking at the rxsubchans field of struct v4l2_tuner: the V4L2_TUNER_SUB_RDS will be set if RDS data was detected.
Devices supporting the RDS output API set the V4L2_CAP_RDS_OUTPUT flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. Any modulator that supports RDS will set the V4L2_TUNER_CAP_RDS flag in the capability field of struct v4l2_modulator. In order to enable the RDS transmission one must set the V4L2_TUNER_SUB_RDS bit in the txsubchans field of struct v4l2_modulator. If the driver only passes RDS blocks without interpreting the data the V4L2_TUNER_CAP_RDS_BLOCK_IO flag has to be set. If the tuner is capable of handling RDS entities like program identification codes and radio text, the flag V4L2_TUNER_CAP_RDS_CONTROLS should be set, see Writing RDS data and FM Transmitter Control Reference.
Reading RDS data #
RDS data can be read from the radio device with the read() function. The data is packed in groups of three bytes.
Writing RDS data #
RDS data can be written to the radio device with the write() function. The data is packed in groups of three bytes, as follows:
RDS datastructures #
v4l2_rds_data
|
__u8 |
|
Least Significant Byte of RDS Block |
|
__u8 |
|
Most Significant Byte of RDS Block |
|
__u8 |
|
Block description |
|
Bits 0-2 |
Block (aka offset) of the received data. |
|
Bits 3-5 |
Deprecated. Currently identical to bits 0-2. Do not use these bits. |
|
Bit 6 |
Corrected bit. Indicates that an error was corrected for this data block. |
|
Bit 7 |
Error bit. Indicates that an uncorrectable error occurred during reception of this block. |
|
V4L2_RDS_BLOCK_MSK |
7 |
Mask for bits 0-2 to get the block ID. |
|
|
V4L2_RDS_BLOCK_A |
0 |
Block A. |
|
|
V4L2_RDS_BLOCK_B |
1 |
Block B. |
|
|
V4L2_RDS_BLOCK_C |
2 |
Block C. |
|
|
V4L2_RDS_BLOCK_D |
3 |
Block D. |
|
|
V4L2_RDS_BLOCK_C_ALT |
4 |
Block C'. |
|
|
V4L2_RDS_BLOCK_INVALID |
read-only |
7 |
An invalid block. |
|
V4L2_RDS_BLOCK_CORRECTED |
read-only |
0x40 |
A bit error was detected but corrected. |
|
V4L2_RDS_BLOCK_ERROR |
read-only |
0x80 |
An uncorrectable error occurred. |
Software Defined Radio Interface (SDR)
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
SDR is an abbreviation of Software Defined Radio, the radio device which uses application software for modulation or demodulation. This interface is intended for controlling and data streaming of such devices.
SDR devices are accessed through character device special files named /dev/swradio0 to /dev/swradio255 with major number 81 and dynamically allocated minor numbers 0 to 255.
Querying Capabilities #
Devices supporting the SDR receiver interface set the V4L2_CAP_SDR_CAPTURE and V4L2_CAP_TUNER flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. That flag means the device has an Analog to Digital Converter (ADC), which is a mandatory element for the SDR receiver.
Devices supporting the SDR transmitter interface set the V4L2_CAP_SDR_OUTPUT and V4L2_CAP_MODULATOR flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl. That flag means the device has an Digital to Analog Converter (DAC), which is a mandatory element for the SDR transmitter.
At least one of the read/write or streaming I/O methods must be supported.
Supplemental Functions #
SDR devices can support controls, and must support the Tuners and Modulators ioctls. Tuner ioctls are used for setting the ADC/DAC sampling rate (sampling frequency) and the possible radio frequency (RF).
The V4L2_TUNER_SDR tuner type is used for setting SDR device ADC/DAC frequency, and the V4L2_TUNER_RF tuner type is used for setting radio frequency. The tuner index of the RF tuner (if any) must always follow the SDR tuner index. Normally the SDR tuner is #0 and the RF tuner is #1.
The ioctl VIDIOC_S_HW_FREQ_SEEK ioctl is not supported.
Data Format Negotiation #
The SDR device uses the Data Formats ioctls to select the capture and output format. Both the sampling resolution and the data streaming format are bound to that selectable format. In addition to the basic Data Formats ioctls, the ioctl VIDIOC_ENUM_FMT ioctl must be supported as well.
To use the Data Formats ioctls applications set the type field of a struct v4l2_format to V4L2_BUF_TYPE_SDR_CAPTURE or V4L2_BUF_TYPE_SDR_OUTPUT and use the struct v4l2_sdr_format sdr member of the fmt union as needed per the desired operation. Currently there are two fields, pixelformat and buffersize, of struct v4l2_sdr_format which are used. Content of the pixelformat is V4L2 FourCC code of the data format. The buffersize field is maximum buffer size in bytes required for data transfer, set by the driver in order to inform application.
v4l2_sdr_format
|
__u32 |
|
The data format or type of compression, set by the application. This is a little endian four character code. V4L2 defines SDR formats in SDR Formats. |
|
__u32 |
|
Maximum size in bytes required for data. Value is set by the driver. |
|
__u8 |
|
This array is reserved for future extensions. Drivers and applications must set it to zero. |
An SDR device may support read/write and/or streaming (memory mapping or user pointer) I/O.
Sliced VBI Data Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
VBI stands for Vertical Blanking Interval, a gap in the sequence of lines of an analog video signal. During VBI no picture information is transmitted, allowing some time while the electron beam of a cathode ray tube TV returns to the top of the screen.
Sliced VBI devices use hardware to demodulate data transmitted in the VBI. V4L2 drivers shall not do this by software, see also the raw VBI interface. The data is passed as short packets of fixed size, covering one scan line each. The number of packets per video frame is variable.
Sliced VBI capture and output devices are accessed through the same character special files as raw VBI devices. When a driver supports both interfaces, the default function of a /dev/vbi device is raw VBI capturing or output, and the sliced VBI function is only available after calling the VIDIOC_S_FMT ioctl as defined below. Likewise a /dev/video device may support the sliced VBI API, however the default function here is video capturing or output. Different file descriptors must be used to pass raw and sliced VBI data simultaneously, if this is supported by the driver.
Querying Capabilities #
Devices supporting the sliced VBI capturing or output API set the V4L2_CAP_SLICED_VBI_CAPTURE or V4L2_CAP_SLICED_VBI_OUTPUT flag respectively, in the capabilities field of struct v4l2_capability returned by the vidioc_querycap ioctl. At least one of the read/write or streaming I/O methods must be supported. Sliced VBI devices may have a tuner or modulator.
Supplemental Functions #
Sliced VBI devices shall support video input or output and tuner or modulator ioctls if they have these capabilities, and they may support control ioctls. The video standard ioctls provide information vital to program a sliced VBI device, therefore must be supported.
Sliced VBI Format Negotiation #
To find out which data services are supported by the hardware applications can call the VIDIOC_G_SLICED_VBI_CAP ioctl. All drivers implementing the sliced VBI interface must support this ioctl. The results may differ from those of the VIDIOC_S_FMT ioctl when the number of VBI lines the hardware can capture or output per frame, or the number of services it can identify on a given line are limited. For example on PAL line 16 the hardware may be able to look for a VPS or Teletext signal, but not both at the same time.
To determine the currently selected services applications set the type field of struct v4l2_format to V4L2_BUF_TYPE_SLICED_VBI_CAPTURE or V4L2_BUF_TYPE_SLICED_VBI_OUTPUT, and the VIDIOC_G_FMT ioctl fills the fmt.sliced member, a struct v4l2_sliced_vbi_format.
Applications can request different parameters by initializing or modifying the fmt.sliced member and calling the VIDIOC_S_FMT ioctl with a pointer to the struct v4l2_format structure.
The sliced VBI API is more complicated than the raw VBI API because the hardware must be told which VBI service to expect on each scan line. Not all services may be supported by the hardware on all lines (this is especially true for VBI output where Teletext is often unsupported and other services can only be inserted in one specific line). In many cases, however, it is sufficient to just set the service_set field to the required services and let the driver fill the service_lines array according to hardware capabilities. Only if more precise control is needed should the programmer set the service_lines array explicitly.
The VIDIOC_S_FMT ioctl modifies the parameters according to hardware capabilities. When the driver allocates resources at this point, it may return an EBUSY error code if the required resources are temporarily unavailable. Other resource allocation points which may return EBUSY can be the vidioc_streamon ioctl and the first read(), write() and select() call.
v4l2_sliced_vbi_format
struct v4l2_sliced_vbi_format #
|
__u16 |
|
If On return the driver sets this field to the union of all elements of the returned |
||
|
__u16 |
|
Applications initialize this array with sets of data services the driver shall look for or insert on the respective scan line. Subject to hardware capabilities drivers return the requested set, a subset, which may be just a single service, or an empty set. When the hardware cannot handle multiple services on the same line the driver shall choose one. No assumptions can be made on which service the driver chooses. Data services are defined in Sliced VBI services. Array indices map to ITU-R line numbers2 as follows: |
||
|
Element |
525 line systems |
625 line systems |
||
|
|
1 |
1 |
||
|
|
23 |
23 |
||
|
|
264 |
314 |
||
|
|
286 |
336 |
||
|
Drivers must set |
||||
|
__u32 |
|
Maximum number of bytes passed by one |
||
|
__u32 |
|
This array is reserved for future extensions. Applications and drivers must set it to zero. |
||
Sliced VBI services #
|
Symbol |
Value |
Reference |
Lines, usually |
Payload |
|---|---|---|---|---|
|
|
0x0001 |
PAL/SECAM line 7-22, 320-335 (second field 7-22) |
Last 42 of the 45 byte Teletext packet, that is without clock run-in and framing code, lsb first transmitted. |
|
|
|
0x0400 |
PAL line 16 |
Byte number 3 to 15 according to Figure 9 of ETS 300 231, lsb first transmitted. |
|
|
|
0x1000 |
NTSC line 21, 284 (second field 21) |
Two bytes in transmission order, including parity bit, lsb first transmitted. |
|
|
|
0x4000 |
PAL/SECAM line 23 |
See V4L2_SLICED_WSS_625 payload below. |
|
|
|
0x1000 |
Set of services applicable to 525 line systems. |
||
|
|
0x4401 |
Set of services applicable to 625 line systems. |
||
Drivers may return an EINVAL error code when applications attempt to read or write data without prior format negotiation, after switching the video standard (which may invalidate the negotiated VBI parameters) and after switching the video input (which may change the video standard as a side effect). The VIDIOC_S_FMT ioctl may return an EBUSY error code when applications attempt to change the format while i/o is in progress (between a vidioc_streamon and VIDIOC_STREAMOFF call, and after the first read() or write() call).
V4L2_SLICED_WSS_625 payload #
The payload for V4L2_SLICED_WSS_625 is:
Byte
0
1
Bit
msb
lsb
msb
lsb
7
6
5
4
3
2
1
0
x
x
13
12
11
10
9
8
Reading and writing sliced VBI data #
A single read() or write() call must pass all data belonging to one video frame. That is an array of struct v4l2_sliced_vbi_data structures with one or more elements and a total size not exceeding io_size bytes. Likewise in streaming I/O mode one buffer of io_size bytes must contain data of one video frame. The id of unused struct v4l2_sliced_vbi_data elements must be zero.
v4l2_sliced_vbi_data
struct v4l2_sliced_vbi_data #
|
__u32 |
|
A flag from vbi-services identifying the type of data in this packet. Only a single bit must be set. When the |
|
__u32 |
|
The video field number this data has been captured from, or shall be inserted at. |
|
__u32 |
|
The field (as opposed to frame) line number this data has been captured from, or shall be inserted at. See vbi-525 and vbi-625 for valid values. Sliced VBI capture devices can set the line number of all packets to |
|
__u32 |
|
This field is reserved for future extensions. Applications and drivers must set it to zero. |
|
__u8 |
|
The packet payload. See vbi-services for the contents and number of bytes passed for each data type. The contents of padding bytes at the end of this array are undefined, drivers and applications shall ignore them. |
Packets are always passed in ascending line number order, without duplicate line numbers. The write() function and the vidioc_qbuf ioctl must return an EINVAL error code when applications violate this rule. They must also return an EINVAL error code when applications pass an incorrect field or line number, or a combination of field, line and id which has not been negotiated with the VIDIOC_G_FMT or VIDIOC_S_FMT ioctl. When the line numbers are unknown the driver must pass the packets in transmitted order. The driver can insert empty packets with id set to zero anywhere in the packet array.
To assure synchronization and to distinguish from frame dropping, when a captured frame does not carry any of the requested data services drivers must pass one or more empty packets. When an application fails to pass VBI data in time for output, the driver must output the last VPS and WSS packet again, and disable the output of Closed Caption and Teletext data, or output data which is ignored by Closed Caption and Teletext decoders.
A sliced VBI device may support read/write and/or streaming (memory mapping and/or user pointer) I/O. The latter bears the possibility of synchronizing video and VBI data by using buffer timestamps.
Sliced VBI Data in MPEG Streams #
If a device can produce an MPEG output stream, it may be capable of providing negotiated sliced VBI services as data embedded in the MPEG stream. Users or applications control this sliced VBI data insertion with the V4L2_CID_MPEG_STREAM_VBI_FMT control.
If the driver does not provide the V4L2_CID_MPEG_STREAM_VBI_FMT control, or only allows that control to be set to V4L2_MPEG_STREAM_VBI_FMT_NONE, then the device cannot embed sliced VBI data in the MPEG stream.
The V4L2_CID_MPEG_STREAM_VBI_FMT control does not implicitly set the device driver to capture nor cease capturing sliced VBI data. The control only indicates to embed sliced VBI data in the MPEG stream, if an application has negotiated sliced VBI service be captured.
It may also be the case that a device can embed sliced VBI data in only certain types of MPEG streams: for example in an MPEG-2 PS but not an MPEG-2 TS. In this situation, if sliced VBI data insertion is requested, the sliced VBI data will be embedded in MPEG stream types when supported, and silently omitted from MPEG stream types where sliced VBI data insertion is not supported by the device.
The following subsections specify the format of the embedded sliced VBI data.
MPEG Stream Embedded, Sliced VBI Data Format: NONE #
The V4L2_MPEG_STREAM_VBI_FMT_NONE embedded sliced VBI format shall be interpreted by drivers as a control to cease embedding sliced VBI data in MPEG streams. Neither the device nor driver shall insert "empty" embedded sliced VBI data packets in the MPEG stream when this format is set. No MPEG stream data structures are specified for this format.
MPEG Stream Embedded, Sliced VBI Data Format: IVTV #
The V4L2_MPEG_STREAM_VBI_FMT_IVTV embedded sliced VBI format, when supported, indicates to the driver to embed up to 36 lines of sliced VBI data per frame in an MPEG-2 Private Stream 1 PES packet encapsulated in an MPEG-2 Program Pack in the MPEG stream.
Historical context: This format specification originates from a custom, embedded, sliced VBI data format used by the ivtv driver. This format has already been informally specified in the kernel sources in the file Documentation/userspace-api/media/drivers/cx2341x-uapi.rst . The maximum size of the payload and other aspects of this format are driven by the CX23415 MPEG decoder's capabilities and limitations with respect to extracting, decoding, and displaying sliced VBI data embedded within an MPEG stream.
This format's use is not exclusive to the ivtv driver nor exclusive to CX2341x devices, as the sliced VBI data packet insertion into the MPEG stream is implemented in driver software. At least the cx18 driver provides sliced VBI data insertion into an MPEG-2 PS in this format as well.
The following definitions specify the payload of the MPEG-2 Private Stream 1 PES packets that contain sliced VBI data when V4L2_MPEG_STREAM_VBI_FMT_IVTV is set. (The MPEG-2 Private Stream 1 PES packet header and encapsulating MPEG-2 Program Pack header are not detailed here. Please refer to the MPEG-2 specifications for details on those packet headers.)
The payload of the MPEG-2 Private Stream 1 PES packets that contain sliced VBI data is specified by struct v4l2_mpeg_vbi_fmt_ivtv. The payload is variable length, depending on the actual number of lines of sliced VBI data present in a video frame. The payload may be padded at the end with unspecified fill bytes to align the end of the payload to a 4-byte boundary. The payload shall never exceed 1552 bytes (2 fields with 18 lines/field with 43 bytes of data/line and a 4 byte magic number).
v4l2_mpeg_vbi_fmt_ivtv
struct v4l2_mpeg_vbi_fmt_ivtv #
|
__u8 |
|
A "magic" constant from Magic Constants for struct v4l2_mpeg_vbi_fmt_ivtv magic field that indicates this is a valid sliced VBI data payload and also indicates which member of the anonymous union, |
|
union { |
(anonymous) |
|
|
struct |
|
The primary form of the sliced VBI data payload that contains anywhere from 1 to 35 lines of sliced VBI data. Line masks are provided in this form of the payload indicating which VBI lines are provided. |
|
struct v4l2_mpeg_vbi_ITV0 |
|
An alternate form of the sliced VBI data payload used when 36 lines of sliced VBI data are present. No line masks are provided in this form of the payload; all valid line mask bits are implicitly set. |
|
} |
||
Magic Constants for struct v4l2_mpeg_vbi_fmt_ivtv magic field #
|
Defined Symbol |
Value |
Description |
|---|---|---|
|
|
"itv0" |
Indicates the |
|
|
"ITV0" |
Indicates the |
v4l2_mpeg_vbi_itv0
v4l2_mpeg_vbi_ITV0
structs v4l2_mpeg_vbi_itv0 and v4l2_mpeg_vbi_ITV0 #
|
__le32 |
|
Bitmasks indicating the VBI service lines present. These |
|
struct |
|
This is a variable length array that holds from 1 to 35 lines of sliced VBI data. The sliced VBI data lines present correspond to the bits set in the |
struct v4l2_mpeg_vbi_ITV0 #
|
struct |
|
A fixed length array of 36 lines of sliced VBI data. |
v4l2_mpeg_vbi_itv0_line
struct v4l2_mpeg_vbi_itv0_line #
|
__u8 |
|
A line identifier value from Line Identifiers for struct v4l2_mpeg_vbi_itv0_line id field that indicates the type of sliced VBI data stored on this line. |
|
__u8 |
|
The sliced VBI data for the line. |
Line Identifiers for struct v4l2_mpeg_vbi_itv0_line id field #
|
Defined Symbol |
Value |
Description |
|---|---|---|
|
|
1 |
Refer to Sliced VBI services for a description of the line payload. |
|
|
4 |
Refer to Sliced VBI services for a description of the line payload. |
|
|
5 |
Refer to Sliced VBI services for a description of the line payload. |
|
|
7 |
Refer to Sliced VBI services for a description of the line payload. |
[1] According to ETS 300 706 lines 6-22 of the first field and lines 5-22 of the second field may carry Teletext data.
Memory-to-memory Stateless Video Decoder Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
A stateless decoder is a decoder that works without retaining any kind of state between processed frames. This means that each frame is decoded independently of any previous and future frames, and that the client is responsible for maintaining the decoding state and providing it to the decoder with each decoding request. This is in contrast to the stateful video decoder interface, where the hardware and driver maintain the decoding state and all the client has to do is to provide the raw encoded stream and dequeue decoded frames in display order.
This section describes how user-space ("the client") is expected to communicate with stateless decoders in order to successfully decode an encoded stream. Compared to stateful codecs, the decoder/client sequence is simpler, but the cost of this simplicity is extra complexity in the client which is responsible for maintaining a consistent decoding state.
Stateless decoders make use of the Request API. A stateless decoder must expose the V4L2_BUF_CAP_SUPPORTS_REQUESTS capability on its OUTPUT queue when VIDIOC_REQBUFS() or VIDIOC_CREATE_BUFS() are invoked.
Depending on the encoded formats supported by the decoder, a single decoded frame may be the result of several decode requests (for instance, H.264 streams with multiple slices per frame). Decoders that support such formats must also expose the V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF capability on their OUTPUT queue.
Querying capabilities #
-
To enumerate the set of coded formats supported by the decoder, the client calls
VIDIOC_ENUM_FMT()on theOUTPUTqueue.-
The driver must always return the full set of supported
OUTPUTformats, irrespective of the format currently set on theCAPTUREqueue. -
Simultaneously, the driver must restrain the set of values returned by codec-specific capability controls (such as H.264 profiles) to the set actually supported by the hardware.
-
-
To enumerate the set of supported raw formats, the client calls
VIDIOC_ENUM_FMT()on theCAPTUREqueue.-
The driver must return only the formats supported for the format currently active on the
OUTPUTqueue. -
Depending on the currently set
OUTPUTformat, the set of supported raw formats may depend on the value of some codec-dependent controls. The client is responsible for making sure that these controls are set before querying theCAPTUREqueue. Failure to do so will result in the default values for these controls being used, and a returned set of formats that may not be usable for the media the client is trying to decode.
-
-
The client may use
VIDIOC_ENUM_FRAMESIZES()to detect supported resolutions for a given format, passing desired pixel format inv4l2_frmsizeenum'spixel_format. -
Supported profiles and levels for the current
OUTPUTformat, if applicable, may be queried using their respective controls viaVIDIOC_QUERYCTRL().
Initialization #
-
Set the coded format on the
OUTPUTqueue viaVIDIOC_S_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
pixelformata coded pixel format.
-
width,heightcoded width and height parsed from the stream.
-
other fields
follow standard semantics.
-
-
-
Call
VIDIOC_S_EXT_CTRLS()to set all the controls (parsed headers, etc.) required by theOUTPUTformat to enumerate theCAPTUREformats. -
Call
VIDIOC_G_FMT()forCAPTUREqueue to get the format for the destination buffers parsed/decoded from the bytestream.-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE.
-
-
Returned fields:
-
width,heightframe buffer resolution for the decoded frames.
-
pixelformatpixel format for decoded frames.
-
num_planes(for _MPLANEtypeonly)number of planes for pixelformat.
-
sizeimage,bytesperlineas per standard semantics; matching frame buffer format.
-
-
-
[optional] Enumerate
CAPTUREformats viaVIDIOC_ENUM_FMT()on theCAPTUREqueue. The client may use this ioctl to discover which alternative raw formats are supported for the currentOUTPUTformat and select one of them viaVIDIOC_S_FMT(). -
[optional] Choose a different
CAPTUREformat than suggested viaVIDIOC_S_FMT()onCAPTUREqueue. It is possible for the client to choose a different format than selected/suggested by the driver inVIDIOC_G_FMT().-
Required fields:
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
pixelformata raw pixel format.
-
width,heightframe buffer resolution of the decoded stream; typically unchanged from what was returned with
VIDIOC_G_FMT(), but it may be different if the hardware supports composition and/or scaling.
-
After performing this step, the client must perform step 3 again in order to obtain up-to-date information about the buffers size and layout.
-
-
Allocate source (bytestream) buffers via
VIDIOC_REQBUFS()onOUTPUTqueue.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero.
-
typea
V4L2_BUF_TYPE_*enum appropriate forOUTPUT. -
memoryfollows standard semantics.
-
-
Returned fields:
-
countactual number of buffers allocated.
-
-
If required, the driver will adjust
countto be equal or bigger to the minimum of required number ofOUTPUTbuffers for the given format and requested count. The client must check this value after the ioctl returns to get the actual number of buffers allocated.
-
-
Allocate destination (raw format) buffers via
VIDIOC_REQBUFS()on theCAPTUREqueue.-
Required fields:
-
countrequested number of buffers to allocate; greater than zero. The client is responsible for deducing the minimum number of buffers required for the stream to be properly decoded (taking e.g. reference frames into account) and pass an equal or bigger number.
-
typea
V4L2_BUF_TYPE_*enum appropriate forCAPTURE. -
memoryfollows standard semantics.
V4L2_MEMORY_USERPTRis not supported forCAPTUREbuffers.
-
-
Returned fields:
-
countadjusted to allocated number of buffers, in case the codec requires more buffers than requested.
-
-
The driver must adjust count to the minimum of required number of
CAPTUREbuffers for the current format, stream configuration and requested count. The client must check this value after the ioctl returns to get the number of buffers allocated.
-
-
-
Allocate requests (likely one per
OUTPUTbuffer) viaMEDIA_IOC_REQUEST_ALLOC()on the media device.
-
-
-
Start streaming on both
OUTPUTandCAPTUREqueues viaVIDIOC_STREAMON().
-
Decoding #
For each frame, the client is responsible for submitting at least one request to which the following is attached:
-
The amount of encoded data expected by the codec for its current configuration, as a buffer submitted to the
OUTPUTqueue. Typically, this corresponds to one frame worth of encoded data, but some formats may allow (or require) different amounts per unit. -
All the metadata needed to decode the submitted encoded data, in the form of controls relevant to the format being decoded.
The amount of data and contents of the source OUTPUT buffer, as well as the controls that must be set on the request, depend on the active coded pixel format and might be affected by codec-specific extended controls, as stated in documentation of each format.
If there is a possibility that the decoded frame will require one or more decode requests after the current one in order to be produced, then the client must set the V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF flag on the OUTPUT buffer. This will result in the (potentially partially) decoded CAPTURE buffer not being made available for dequeueing, and reused for the next decode request if the timestamp of the next OUTPUT buffer has not changed.
A typical frame would thus be decoded using the following sequence:
-
Queue an
OUTPUTbuffer containing one unit of encoded bytestream data for the decoding request, usingVIDIOC_QBUF().-
Required fields:
-
indexindex of the buffer being queued.
-
typetype of the buffer.
-
bytesusednumber of bytes taken by the encoded data frame in the buffer.
-
flagsthe
V4L2_BUF_FLAG_REQUEST_FDflag must be set. Additionally, if we are not sure that the current decode request is the last one needed to produce a fully decoded frame, thenV4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUFmust also be set. -
request_fdmust be set to the file descriptor of the decoding request.
-
timestampmust be set to a unique value per frame. This value will be propagated into the decoded frame's buffer and can also be used to use this frame as the reference of another. If using multiple decode requests per frame, then the timestamps of all the
OUTPUTbuffers for a given frame must be identical. If the timestamp changes, then the currently heldCAPTUREbuffer will be made available for dequeuing and the current request will work on a newCAPTUREbuffer.
-
-
-
Set the codec-specific controls for the decoding request, using
VIDIOC_S_EXT_CTRLS().-
Required fields:
-
whichmust be
V4L2_CTRL_WHICH_REQUEST_VAL. -
request_fdmust be set to the file descriptor of the decoding request.
-
other fields
other fields are set as usual when setting controls. The
controlsarray must contain all the codec-specific controls required to decode a frame.
-
-
-
Submit the request by invoking
MEDIA_REQUEST_IOC_QUEUE()on the request FD.If the request is submitted without an
OUTPUTbuffer, or if some of the required controls are missing from the request, thenMEDIA_REQUEST_IOC_QUEUE()will return-ENOENT. If more than oneOUTPUTbuffer is queued, then it will return-EINVAL.MEDIA_REQUEST_IOC_QUEUE()returning non-zero means that noCAPTUREbuffer will be produced for this request.
CAPTURE buffers must not be part of the request, and are queued independently. They are returned in decode order (i.e. the same order as coded frames were submitted to the OUTPUT queue).
Runtime decoding errors are signaled by the dequeued CAPTURE buffers carrying the V4L2_BUF_FLAG_ERROR flag. If a decoded reference frame has an error, then all following decoded frames that refer to it also have the V4L2_BUF_FLAG_ERROR flag set, although the decoder will still try to produce (likely corrupted) frames.
Buffer management while decoding #
Contrary to stateful decoders, a stateless decoder does not perform any kind of buffer management: it only guarantees that dequeued CAPTURE buffers can be used by the client for as long as they are not queued again. "Used" here encompasses using the buffer for compositing or display.
A dequeued capture buffer can also be used as the reference frame of another buffer.
A frame is specified as reference by converting its timestamp into nanoseconds, and storing it into the relevant member of a codec-dependent control structure. The v4l2_timeval_to_ns() function must be used to perform that conversion. The timestamp of a frame can be used to reference it as soon as all its units of encoded data are successfully submitted to the OUTPUT queue.
A decoded buffer containing a reference frame must not be reused as a decoding target until all the frames referencing it have been decoded. The safest way to achieve this is to refrain from queueing a reference buffer until all the decoded frames referencing it have been dequeued. However, if the driver can guarantee that buffers queued to the CAPTURE queue are processed in queued order, then user-space can take advantage of this guarantee and queue a reference buffer when the following conditions are met:
-
All the requests for frames affected by the reference frame have been queued, and
-
A sufficient number of
CAPTUREbuffers to cover all the decoded referencing frames have been queued.
When queuing a decoding request, the driver will increase the reference count of all the resources associated with reference frames. This means that the client can e.g. close the DMABUF file descriptors of reference frame buffers if it won't need them afterwards.
Seeking #
In order to seek, the client just needs to submit requests using input buffers corresponding to the new stream position. It must however be aware that resolution may have changed and follow the dynamic resolution change sequence in that case. Also depending on the codec used, picture parameters (e.g. SPS/PPS for H.264) may have changed and the client is responsible for making sure that a valid state is sent to the decoder.
The client is then free to ignore any returned CAPTURE buffer that comes from the pre-seek position.
Pausing #
In order to pause, the client can just cease queuing buffers onto the OUTPUT queue. Without source bytestream data, there is no data to process and the codec will remain idle.
Dynamic resolution change #
If the client detects a resolution change in the stream, it will need to perform the initialization sequence again with the new resolution:
-
If the last submitted request resulted in a
CAPTUREbuffer being held by the use of theV4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUFflag, then the last frame is not available on theCAPTUREqueue. In this case, aV4L2_DEC_CMD_FLUSHcommand shall be sent. This will make the driver dequeue the heldCAPTUREbuffer. -
Wait until all submitted requests have completed and dequeue the corresponding output buffers.
-
Call
VIDIOC_STREAMOFF()on both theOUTPUTandCAPTUREqueues. -
Free all
CAPTUREbuffers by callingVIDIOC_REQBUFS()on theCAPTUREqueue with a buffer count of zero. -
Perform the initialization sequence again (minus the allocation of
OUTPUTbuffers), with the new resolution set on theOUTPUTqueue. Note that due to resolution constraints, a different format may need to be picked on theCAPTUREqueue.
Drain #
If the last submitted request resulted in a CAPTURE buffer being held by the use of the V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF flag, then the last frame is not available on the CAPTURE queue. In this case, a V4L2_DEC_CMD_FLUSH command shall be sent. This will make the driver dequeue the held CAPTURE buffer.
After that, in order to drain the stream on a stateless decoder, the client just needs to wait until all the submitted requests are completed.
Sub-device Interface
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The complex nature of V4L2 devices, where hardware is often made of several integrated circuits that need to interact with each other in a controlled way, leads to complex V4L2 drivers. The drivers usually reflect the hardware model in software, and model the different hardware components as software blocks called sub-devices.
V4L2 sub-devices are usually kernel-only objects. If the V4L2 driver implements the media device API, they will automatically inherit from media entities. Applications will be able to enumerate the sub-devices and discover the hardware topology using the media entities, pads and links enumeration API.
In addition to make sub-devices discoverable, drivers can also choose to make them directly configurable by applications. When both the sub-device driver and the V4L2 device driver support this, sub-devices will feature a character device node on which ioctls can be called to
-
query, read and write sub-devices controls
-
subscribe and unsubscribe to events and retrieve them
-
negotiate image formats on individual pads
-
inspect and modify internal data routing between pads of the same entity
Sub-device character device nodes, conventionally named /dev/v4l-subdev*, use major number 81.
Drivers may opt to limit the sub-device character devices to only expose operations that do not modify the device state. In such a case the sub-devices are referred to as read-only in the rest of this documentation, and the related restrictions are documented in individual ioctls.
Controls #
Most V4L2 controls are implemented by sub-device hardware. Drivers usually merge all controls and expose them through video device nodes. Applications can control all sub-devices through a single interface.
Complex devices sometimes implement the same control in different pieces of hardware. This situation is common in embedded platforms, where both sensors and image processing hardware implement identical functions, such as contrast adjustment, white balance or faulty pixels correction. As the V4L2 controls API doesn't support several identical controls in a single device, all but one of the identical controls are hidden.
Applications can access those hidden controls through the sub-device node with the V4L2 control API described in control. The ioctls behave identically as when issued on V4L2 device nodes, with the exception that they deal only with controls implemented in the sub-device.
Depending on the driver, those controls might also be exposed through one (or several) V4L2 device nodes.
Events #
V4L2 sub-devices can notify applications of events as described in event. The API behaves identically as when used on V4L2 device nodes, with the exception that it only deals with events generated by the sub-device. Depending on the driver, those events might also be reported on one (or several) V4L2 device nodes.
Pad-level Formats #
Image formats are typically negotiated on video capture and output devices using the format and selection ioctls. The driver is responsible for configuring every block in the video pipeline according to the requested format at the pipeline input and/or output.
For complex devices, such as often found in embedded systems, identical image sizes at the output of a pipeline can be achieved using different hardware configurations. One such example is shown on pipeline-scaling, where image scaling can be performed on both the video sensor and the host image processing hardware.
flowchart TB n0["pad 0<br/>Host<br/>Scaler<br/>pad 1"] n1["pad 0<br/>Host<br/>Frontend<br/>pad 1"] n2["Sensor<br/>pad 0"] n3["pad 0<br/>V4L I/O"] n2 -->|"HQ: 2592x1968<br/>HS: 1296x984<br/>pad 0 → pad 0"| n1 n1 -->|"HQ: 2592x1968<br/>HS: 1296x984<br/>pad 1 → pad 0"| n0 n0 -->|"HQ: 1280x720<br/>HS: 1280x720<br/>pad 1 → pad 0"| n3 style n0 fill:lightblue,color:#111 style n1 fill:lightblue,color:#111 style n2 fill:aquamarine,color:#111 style n3 fill:aquamarine,color:#111 linkStyle 0 stroke:blue linkStyle 1 stroke:blue linkStyle 2 stroke:blue
pipeline.dot
Image Format Negotiation on Pipelines
High quality and high speed pipeline configuration
The sensor scaler is usually of less quality than the host scaler, but scaling on the sensor is required to achieve higher frame rates. Depending on the use case (quality vs. speed), the pipeline must be configured differently. Applications need to configure the formats at every point in the pipeline explicitly.
Drivers that implement the media API can expose pad-level image format configuration to applications. When they do, applications can use the VIDIOC_SUBDEV_G_FMT and VIDIOC_SUBDEV_S_FMT ioctls. to negotiate formats on a per-pad basis.
Applications are responsible for configuring coherent parameters on the whole pipeline and making sure that connected pads have compatible formats. The pipeline is checked for formats mismatch at VIDIOC_STREAMON time, and an EPIPE error code is then returned if the configuration is invalid.
Pad-level image format configuration support can be tested by calling the vidioc_subdev_g_fmt ioctl on pad 0. If the driver returns an EINVAL error code pad-level format configuration is not supported by the sub-device.
Format Negotiation #
Acceptable formats on pads can (and usually do) depend on a number of external parameters, such as formats on other pads, active links, or even controls. Finding a combination of formats on all pads in a video pipeline, acceptable to both application and driver, can't rely on formats enumeration only. A format negotiation mechanism is required.
Central to the format negotiation mechanism are the get/set format operations. When called with the which argument set to V4L2_SUBDEV_FORMAT_TRY, the VIDIOC_SUBDEV_G_FMT and VIDIOC_SUBDEV_S_FMT ioctls operate on a set of formats parameters that are not connected to the hardware configuration. Modifying those 'try' formats leaves the device state untouched (this applies to both the software state stored in the driver and the hardware state stored in the device itself).
While not kept as part of the device state, try formats are stored in the sub-device file handles. A VIDIOC_SUBDEV_G_FMT call will return the last try format set on the same sub-device file handle. Several applications querying the same sub-device at the same time will thus not interact with each other.
To find out whether a particular format is supported by the device, applications use the VIDIOC_SUBDEV_S_FMT ioctl. Drivers verify and, if needed, change the requested format based on device requirements and return the possibly modified value. Applications can then choose to try a different format or accept the returned value and continue.
Formats returned by the driver during a negotiation iteration are guaranteed to be supported by the device. In particular, drivers guarantee that a returned format will not be further changed if passed to an VIDIOC_SUBDEV_S_FMT call as-is (as long as external parameters, such as formats on other pads or links' configuration are not changed).
Drivers automatically propagate formats inside sub-devices. When a try or active format is set on a pad, corresponding formats on other pads of the same sub-device can be modified by the driver. Drivers are free to modify formats as required by the device. However, they should comply with the following rules when possible:
-
Formats should be propagated from sink pads to source pads. Modifying a format on a source pad should not modify the format on any sink pad.
-
Sub-devices that scale frames using variable scaling factors should reset the scale factors to default values when sink pads formats are modified. If the 1:1 scaling ratio is supported, this means that source pads formats should be reset to the sink pads formats.
Formats are not propagated across links, as that would involve propagating them from one sub-device file handle to another. Applications must then take care to configure both ends of every link explicitly with compatible formats. Identical formats on the two ends of a link are guaranteed to be compatible. Drivers are free to accept different formats matching device requirements as being compatible.
sample-pipeline-config shows a sample configuration sequence for the pipeline described in pipeline-scaling (table columns list entity names and pad numbers).
|
Sensor/0 format |
Frontend/0 format |
Frontend/1 format |
Scaler/0 format |
Scaler/0 compose selection rectangle |
Scaler/1 format |
|
|---|---|---|---|---|---|---|
|
Initial state |
2048x1536 SGRBG8_1X8 |
(default) |
(default) |
(default) |
(default) |
(default) |
|
Configure frontend sink format |
2048x1536 SGRBG8_1X8 |
2048x1536 SGRBG8_1X8 |
2046x1534 SGRBG8_1X8 |
(default) |
(default) |
(default) |
|
Configure scaler sink format |
2048x1536 SGRBG8_1X8 |
2048x1536 SGRBG8_1X8 |
2046x1534 SGRBG8_1X8 |
2046x1534 SGRBG8_1X8 |
0,0/2046x1534 |
2046x1534 SGRBG8_1X8 |
|
Configure scaler sink compose selection |
2048x1536 SGRBG8_1X8 |
2048x1536 SGRBG8_1X8 |
2046x1534 SGRBG8_1X8 |
2046x1534 SGRBG8_1X8 |
0,0/1280x960 |
1280x960 SGRBG8_1X8 |
-
Initial state. The sensor source pad format is set to its native 3MP size and V4L2_MBUS_FMT_SGRBG8_1X8 media bus code. Formats on the host frontend and scaler sink and source pads have the default values, as well as the compose rectangle on the scaler's sink pad.
-
The application configures the frontend sink pad format's size to 2048x1536 and its media bus code to V4L2_MBUS_FMT_SGRBG_1X8. The driver propagates the format to the frontend source pad.
-
The application configures the scaler sink pad format's size to 2046x1534 and the media bus code to V4L2_MBUS_FMT_SGRBG_1X8 to match the frontend source size and media bus code. The media bus code on the sink pad is set to V4L2_MBUS_FMT_SGRBG_1X8. The driver propagates the size to the compose selection rectangle on the scaler's sink pad, and the format to the scaler source pad.
-
The application configures the size of the compose selection rectangle of the scaler's sink pad 1280x960. The driver propagates the size to the scaler's source pad format.
When satisfied with the try results, applications can set the active formats by setting the which argument to V4L2_SUBDEV_FORMAT_ACTIVE. Active formats are changed exactly as try formats by drivers. To avoid modifying the hardware state during format negotiation, applications should negotiate try formats first and then modify the active settings using the try formats returned during the last negotiation iteration. This guarantees that the active format will be applied as-is by the driver without being modified.
Selections: cropping, scaling and composition #
Many sub-devices support cropping frames on their input or output pads (or possible even on both). Cropping is used to select the area of interest in an image, typically on an image sensor or a video decoder. It can also be used as part of digital zoom implementations to select the area of the image that will be scaled up.
Crop settings are defined by a crop rectangle and represented in a struct v4l2_rect by the coordinates of the top left corner and the rectangle size. Both the coordinates and sizes are expressed in pixels.
As for pad formats, drivers store try and active rectangles for the selection targets v4l2-selections-common.
On sink pads, cropping is applied relative to the current pad format. The pad format represents the image size as received by the sub-device from the previous block in the pipeline, and the crop rectangle represents the sub-image that will be transmitted further inside the sub-device for processing.
The scaling operation changes the size of the image by scaling it to new dimensions. The scaling ratio isn't specified explicitly, but is implied from the original and scaled image sizes. Both sizes are represented by struct v4l2_rect.
Scaling support is optional. When supported by a subdev, the crop rectangle on the subdev's sink pad is scaled to the size configured using the VIDIOC_SUBDEV_S_SELECTION IOCTL using V4L2_SEL_TGT_COMPOSE selection target on the same pad. If the subdev supports scaling but not composing, the top and left values are not used and must always be set to zero.
On source pads, cropping is similar to sink pads, with the exception that the source size from which the cropping is performed, is the COMPOSE rectangle on the sink pad. In both sink and source pads, the crop rectangle must be entirely contained inside the source image size for the crop operation.
The drivers should always use the closest possible rectangle the user requests on all selection targets, unless specifically told otherwise. V4L2_SEL_FLAG_GE and V4L2_SEL_FLAG_LE flags may be used to round the image size either up or down. Selection flags
Types of selection targets #
Actual targets #
Actual targets (without a postfix) reflect the actual hardware configuration at any point of time. There is a BOUNDS target corresponding to every actual target.
BOUNDS targets #
BOUNDS targets is the smallest rectangle that contains all valid actual rectangles. It may not be possible to set the actual rectangle as large as the BOUNDS rectangle, however. This may be because e.g. a sensor's pixel array is not rectangular but cross-shaped or round. The maximum size may also be smaller than the BOUNDS rectangle.
Order of configuration and format propagation #
Inside subdevs, the order of image processing steps will always be from the sink pad towards the source pad. This is also reflected in the order in which the configuration must be performed by the user: the changes made will be propagated to any subsequent stages. If this behaviour is not desired, the user must set V4L2_SEL_FLAG_KEEP_CONFIG flag. This flag causes no propagation of the changes are allowed in any circumstances. This may also cause the accessed rectangle to be adjusted by the driver, depending on the properties of the underlying hardware.
The coordinates to a step always refer to the actual size of the previous step. The exception to this rule is the sink compose rectangle, which refers to the sink compose bounds rectangle --- if it is supported by the hardware.
-
Sink pad format. The user configures the sink pad format. This format defines the parameters of the image the entity receives through the pad for further processing.
-
Sink pad actual crop selection. The sink pad crop defines the crop performed to the sink pad format.
-
Sink pad actual compose selection. The size of the sink pad compose rectangle defines the scaling ratio compared to the size of the sink pad crop rectangle. The location of the compose rectangle specifies the location of the actual sink compose rectangle in the sink compose bounds rectangle.
-
Source pad actual crop selection. Crop on the source pad defines crop performed to the image in the sink compose bounds rectangle.
-
Source pad format. The source pad format defines the output pixel format of the subdev, as well as the other parameters with the exception of the image width and height. Width and height are defined by the size of the source pad actual crop selection.
Accessing any of the above rectangles not supported by the subdev will return EINVAL. Any rectangle referring to a previous unsupported rectangle coordinates will instead refer to the previous supported rectangle. For example, if sink crop is not supported, the compose selection will refer to the sink pad format dimensions instead.
Image processing in subdevs: simple crop example
In the above example, the subdev supports cropping on its sink pad. To configure it, the user sets the media bus format on the subdev's sink pad. Now the actual crop rectangle can be set on the sink pad --- the location and size of this rectangle reflect the location and size of a rectangle to be cropped from the sink format. The size of the sink crop rectangle will also be the size of the format of the subdev's source pad.
Image processing in subdevs: scaling with multiple sources
In this example, the subdev is capable of first cropping, then scaling and finally cropping for two source pads individually from the resulting scaled image. The location of the scaled image in the cropped image is ignored in sink compose target. Both of the locations of the source crop rectangles refer to the sink scaling rectangle, independently cropping an area at location specified by the source crop rectangle from it.
Image processing in subdevs: scaling and composition with multiple sinks and sources
The subdev driver supports two sink pads and two source pads. The images from both of the sink pads are individually cropped, then scaled and further composed on the composition bounds rectangle. From that, two independent streams are cropped and sent out of the subdev from the source pads.
Streams, multiplexed media pads and internal routing #
Simple V4L2 sub-devices do not support multiple, unrelated video streams, and only a single stream can pass through a media link and a media pad. Thus each pad contains a format and selection configuration for that single stream. A subdev can do stream processing and split a stream into two or compose two streams into one, but the inputs and outputs for the subdev are still a single stream per pad.
Some hardware, e.g. MIPI CSI-2, support multiplexed streams, that is, multiple data streams are transmitted on the same bus, which is represented by a media link connecting a transmitter source pad with a sink pad on the receiver. For example, a camera sensor can produce two distinct streams, a pixel stream and a metadata stream, which are transmitted on the multiplexed data bus, represented by a media link which connects the single sensor's source pad with the receiver sink pad. The stream-aware receiver will de-multiplex the streams received on the its sink pad and allows to route them individually to one of its source pads.
Subdevice drivers that support multiplexed streams are compatible with non-multiplexed subdev drivers. However, if the driver at the sink end of a link does not support streams, then only stream 0 of source end may be captured. There may be additional limitations specific to the sink device.
Understanding streams #
A stream is a stream of content (e.g. pixel data or metadata) flowing through the media pipeline from a source (e.g. a sensor) towards the final sink (e.g. a receiver and demultiplexer in a SoC). Each media link carries all the enabled streams from one end of the link to the other, and sub-devices have routing tables which describe how the incoming streams from sink pads are routed to the source pads.
A stream ID is a media pad-local identifier for a stream. Streams IDs of the same stream must be equal on both ends of a link. In other words, a particular stream ID must exist on both sides of a media link, but another stream ID can be used for the same stream at the other side of the sub-device.
A stream at a specific point in the media pipeline is identified by the sub-device and a (pad, stream) pair. For sub-devices that do not support multiplexed streams the 'stream' field is always 0.
Interaction between routes, streams, formats and selections #
The addition of streams to the V4L2 sub-device interface moves the sub-device formats and selections from pads to (pad, stream) pairs. Besides the usual pad, also the stream ID needs to be provided for setting formats and selections. The order of configuring formats and selections along a stream is the same as without streams (see Order of configuration and format propagation).
Instead of the sub-device wide merging of streams from all sink pads towards all source pads, data flows for each route are separate from each other. Any number of routes from streams on sink pads towards streams on source pads is allowed, to the extent supported by drivers. For every stream on a source pad, however, only a single route is allowed.
Any configurations of a stream within a pad, such as format or selections, are independent of similar configurations on other streams. This is subject to change in the future.
Device types and routing setup #
Different kinds of sub-devices have differing behaviour for route activation, depending on the hardware. In all cases, however, only routes that have the V4L2_SUBDEV_ROUTE_FL_ACTIVE flag set are active.
Devices generating the streams may allow enabling and disabling some of the routes or have a fixed routing configuration. If the routes can be disabled, not declaring the routes (or declaring them without V4L2_SUBDEV_ROUTE_FL_ACTIVE flag set) in VIDIOC_SUBDEV_S_ROUTING will disable the routes. VIDIOC_SUBDEV_S_ROUTING will still return such routes back to the user in the routes array, with the V4L2_SUBDEV_ROUTE_FL_ACTIVE flag unset.
Devices transporting the streams almost always have more configurability with respect to routing. Typically any route between the sub-device's sink and source pads is possible, and multiple routes (usually up to certain limited number) may be active simultaneously. For such devices, no routes are created by the driver and user-created routes are fully replaced when VIDIOC_SUBDEV_S_ROUTING is called on the sub-device. Such newly created routes have the device's default configuration for format and selection rectangles.
Configuring streams #
The configuration of the streams is done individually for each sub-device and the validity of the streams between sub-devices is validated when the pipeline is started.
There are three steps in configuring the streams:
-
Set up links. Connect the pads between sub-devices using the Media Controller API
-
Streams. Streams are declared and their routing is configured by setting the routing table for the sub-device using VIDIOC_SUBDEV_S_ROUTING ioctl. Note that setting the routing table will reset formats and selections in the sub-device to default values.
-
Configure formats and selections. Formats and selections of each stream are configured separately as documented for plain sub-devices in Order of configuration and format propagation. The stream ID is set to the same stream ID associated with either sink or source pads of routes configured using the VIDIOC_SUBDEV_S_ROUTING ioctl.
Multiplexed streams setup example #
A simple example of a multiplexed stream setup might be as follows:
-
Two identical sensors (Sensor A and Sensor B). Each sensor has a single source pad (pad 0) which carries a pixel data stream.
-
Multiplexer bridge (Bridge). The bridge has two sink pads, connected to the sensors (pads 0, 1), and one source pad (pad 2), which outputs two streams.
-
Receiver in the SoC (Receiver). The receiver has a single sink pad (pad 0), connected to the bridge, and two source pads (pads 1-2), going to the DMA engine. The receiver demultiplexes the incoming streams to the source pads.
-
DMA Engines in the SoC (DMA Engine), one for each stream. Each DMA engine is connected to a single source pad in the receiver.
The sensors, the bridge and the receiver are modeled as V4L2 sub-devices, exposed to userspace via /dev/v4l-subdevX device nodes. The DMA engines are modeled as V4L2 devices, exposed to userspace via /dev/videoX nodes.
To configure this pipeline, the userspace must take the following steps:
-
Set up media links between entities: connect the sensors to the bridge, bridge to the receiver, and the receiver to the DMA engines. This step does not differ from normal non-multiplexed media controller setup.
-
Configure routing
|
Sink Pad/Stream |
Source Pad/Stream |
Routing Flags |
Comments |
|---|---|---|---|
|
0/0 |
2/0 |
V4L2_SUBDEV_ROUTE_FL_ACTIVE |
Pixel data stream from Sensor A |
|
1/0 |
2/1 |
V4L2_SUBDEV_ROUTE_FL_ACTIVE |
Pixel data stream from Sensor B |
|
Sink Pad/Stream |
Source Pad/Stream |
Routing Flags |
Comments |
|---|---|---|---|
|
0/0 |
1/0 |
V4L2_SUBDEV_ROUTE_FL_ACTIVE |
Pixel data stream from Sensor A |
|
0/1 |
2/0 |
V4L2_SUBDEV_ROUTE_FL_ACTIVE |
Pixel data stream from Sensor B |
-
Configure formats and selections
After configuring routing, the next step is configuring the formats and selections for the streams. This is similar to performing this step without streams, with just one exception: the
streamfield needs to be assigned to the value of the stream ID.A common way to accomplish this is to start from the sensors and propagate the configurations along the stream towards the receiver, using VIDIOC_SUBDEV_S_FMT ioctls to configure each stream endpoint in each sub-device.
Touch Devices
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Touch devices are accessed through character device special files named /dev/v4l-touch0 to /dev/v4l-touch255 with major number 81 and dynamically allocated minor numbers 0 to 255.
Overview #
Sensors may be Optical, or Projected Capacitive touch (PCT).
Processing is required to analyse the raw data and produce input events. In some systems, this may be performed on the ASIC and the raw data is purely a side-channel for diagnostics or tuning. In other systems, the ASIC is a simple analogue front end device which delivers touch data at high rate, and any touch processing must be done on the host.
For capacitive touch sensing, the touchscreen is composed of an array of horizontal and vertical conductors (alternatively called rows/columns, X/Y lines, or tx/rx). Mutual Capacitance measured is at the nodes where the conductors cross. Alternatively, Self Capacitance measures the signal from each column and row independently.
A touch input may be determined by comparing the raw capacitance measurement to a no-touch reference (or "baseline") measurement:
Delta = Raw - Reference
The reference measurement takes account of variations in the capacitance across the touch sensor matrix, for example manufacturing irregularities, environmental or edge effects.
Querying Capabilities #
Devices supporting the touch interface set the V4L2_CAP_VIDEO_CAPTURE flag and the V4L2_CAP_TOUCH flag in the capabilities field of v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl.
At least one of the read/write or streaming I/O methods must be supported.
The formats supported by touch devices are documented in Touch Formats.
Data Format Negotiation #
A touch device may support any I/O method.
Interfaces
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
- Video Capture Interface
- Video Overlay Interface
- Video Output Interface
- Video Output Overlay Interface
- Video Memory-To-Memory Interface
- Raw VBI Data Interface
- dev-sliced-vbi
- Radio Interface
- RDS Interface
- Software Defined Radio Interface (SDR)
- Touch Devices
- Event Interface
- dev-subdev
- Metadata Interface
Differences between V4L and V4L2
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Video For Linux API was first introduced in Linux 2.1 to unify and replace various TV and radio device related interfaces, developed independently by driver writers in prior years. Starting with Linux 2.5 the much improved V4L2 API replaces the V4L API. The support for the old V4L calls were removed from Kernel, but the library libv4l supports the conversion of a V4L API system call into a V4L2 one.
Opening and Closing Devices #
For compatibility reasons the character device file names recommended for V4L2 video capture, overlay, radio and raw vbi capture devices did not change from those used by V4L. They are listed in devices and below in v4l-dev.
The teletext devices (minor range 192-223) have been removed in V4L2 and no longer exist. There is no hardware available anymore for handling pure teletext. Instead raw or sliced VBI is used.
The V4L videodev module automatically assigns minor numbers to drivers in load order, depending on the registered device type. We recommend that V4L2 drivers by default register devices with the same numbers, but the system administrator can assign arbitrary minor numbers using driver module options. The major device number remains 81.
|
Device Type |
File Name |
Minor Numbers |
|---|---|---|
|
Video capture and overlay |
|
0-63 |
|
Radio receiver |
|
64-127 |
|
Raw VBI capture |
|
224-255 |
V4L prohibits (or used to prohibit) multiple opens of a device file. V4L2 drivers may support multiple opens, see open for details and consequences.
V4L drivers respond to V4L2 ioctls with an EINVAL error code.
Querying Capabilities #
The V4L VIDIOCGCAP ioctl is equivalent to V4L2's vidioc_querycap.
The name field in struct video_capability became card in struct v4l2_capability, type was replaced by capabilities. Note V4L2 does not distinguish between device types like this, better think of basic video input, video output and radio devices supporting a set of related functions like video capturing, video overlay and VBI capturing. See open for an introduction.
|
|
struct |
Purpose |
|---|---|---|
|
|
|
The video capture interface is supported. |
|
|
|
The device has a tuner or modulator. |
|
|
|
The raw VBI capture interface is supported. |
|
|
|
The video overlay interface is supported. |
|
|
|
Whether chromakey overlay is supported. For more information on overlay see Video Overlay Interface. |
|
|
|
Whether clipping the overlaid image is supported, see Video Overlay Interface. |
|
|
|
Whether overlay overwrites frame buffer memory, see Video Overlay Interface. |
|
|
|
This flag indicates if the hardware can scale images. The V4L2 API implies the scale factor by setting the cropping dimensions and image size with the VIDIOC_S_CROP and VIDIOC_S_FMT ioctl, respectively. The driver returns the closest sizes possible. For more information on cropping and scaling see crop. |
|
|
|
Applications can enumerate the supported image formats with the vidioc_enum_fmt ioctl to determine if the device supports grey scale capturing only. For more information on image formats see pixfmt. |
|
|
|
Applications can call the VIDIOC_G_CROP ioctl to determine if the device supports capturing a subsection of the full picture ("cropping" in V4L2). If not, the ioctl returns the |
|
|
|
Applications can enumerate the supported image formats with the vidioc_enum_fmt ioctl to determine if the device supports MPEG streams. |
|
|
|
See above. |
|
|
|
See above. |
|
|
|
See above. |
The audios field was replaced by capabilities flag V4L2_CAP_AUDIO, indicating if the device has any audio inputs or outputs. To determine their number applications can enumerate audio inputs with the VIDIOC_G_AUDIO ioctl. The audio ioctls are described in Audio.
The maxwidth, maxheight, minwidth and minheight fields were removed. Calling the VIDIOC_S_FMT or VIDIOC_TRY_FMT ioctl with the desired dimensions returns the closest size possible, taking into account the current video standard, cropping and scaling limitations.
Video Sources #
V4L provides the VIDIOCGCHAN and VIDIOCSCHAN ioctl using struct video_channel to enumerate the video inputs of a V4L device. The equivalent V4L2 ioctls are vidioc_enuminput, VIDIOC_G_INPUT and VIDIOC_S_INPUT using struct v4l2_input as discussed in video.
The channel field counting inputs was renamed to index, the video input types were renamed as follows:
|
struct |
struct |
|---|---|
|
|
|
|
|
|
Unlike the tuners field expressing the number of tuners of this input, V4L2 assumes each video input is connected to at most one tuner. However a tuner can have more than one input, i. e. RF connectors, and a device can have multiple tuners. The index number of the tuner associated with the input, if any, is stored in field tuner of struct v4l2_input. Enumeration of tuners is discussed in tuner.
The redundant VIDEO_VC_TUNER flag was dropped. Video inputs associated with a tuner are of type V4L2_INPUT_TYPE_TUNER. The VIDEO_VC_AUDIO flag was replaced by the audioset field. V4L2 considers devices with up to 32 audio inputs. Each set bit in the audioset field represents one audio input this video input combines with. For information about audio inputs and how to switch between them see Audio.
The norm field describing the supported video standards was replaced by std. The V4L specification mentions a flag VIDEO_VC_NORM indicating whether the standard can be changed. This flag was a later addition together with the norm field and has been removed in the meantime. V4L2 has a similar, albeit more comprehensive approach to video standards, see standard for more information.
Tuning #
The V4L VIDIOCGTUNER and VIDIOCSTUNER ioctl and struct video_tuner can be used to enumerate the tuners of a V4L TV or radio device. The equivalent V4L2 ioctls are VIDIOC_G_TUNER and VIDIOC_S_TUNER using struct v4l2_tuner. Tuners are covered in tuner.
The tuner field counting tuners was renamed to index. The fields name, rangelow and rangehigh remained unchanged.
The VIDEO_TUNER_PAL, VIDEO_TUNER_NTSC and VIDEO_TUNER_SECAM flags indicating the supported video standards were dropped. This information is now contained in the associated struct v4l2_input. No replacement exists for the VIDEO_TUNER_NORM flag indicating whether the video standard can be switched. The mode field to select a different video standard was replaced by a whole new set of ioctls and structures described in standard. Due to its ubiquity it should be mentioned the BTTV driver supports several standards in addition to the regular VIDEO_MODE_PAL (0), VIDEO_MODE_NTSC, VIDEO_MODE_SECAM and VIDEO_MODE_AUTO (3). Namely N/PAL Argentina, M/PAL, N/PAL, and NTSC Japan with numbers 3-6 (sic).
The VIDEO_TUNER_STEREO_ON flag indicating stereo reception became V4L2_TUNER_SUB_STEREO in field rxsubchans. This field also permits the detection of monaural and bilingual audio, see the definition of struct v4l2_tuner for details. Presently no replacement exists for the VIDEO_TUNER_RDS_ON and VIDEO_TUNER_MBS_ON flags.
The VIDEO_TUNER_LOW flag was renamed to V4L2_TUNER_CAP_LOW in the struct v4l2_tuner capability field.
The VIDIOCGFREQ and VIDIOCSFREQ ioctl to change the tuner frequency where renamed to VIDIOC_G_FREQUENCY and VIDIOC_S_FREQUENCY. They take a pointer to a struct v4l2_frequency instead of an unsigned long integer.
Image Properties #
V4L2 has no equivalent of the VIDIOCGPICT and VIDIOCSPICT ioctl and struct video_picture. The following fields where replaced by V4L2 controls accessible with the ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU, VIDIOC_G_CTRL and VIDIOC_S_CTRL ioctls:
|
struct |
V4L2 Control ID |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The V4L picture controls are assumed to range from 0 to 65535 with no particular reset value. The V4L2 API permits arbitrary limits and defaults which can be queried with the ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU ioctl. For general information about controls see control.
The depth (average number of bits per pixel) of a video image is implied by the selected image format. V4L2 does not explicitly provide such information assuming applications recognizing the format are aware of the image depth and others need not know. The palette field moved into the struct v4l2_pix_format:
|
struct |
struct |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
None |
|
|
|
|
|
None 7 |
|
|
|
|
|
|
|
|
|
|
|
V4L2 image formats are defined in pixfmt. The image format can be selected with the VIDIOC_S_FMT ioctl.
Audio #
The VIDIOCGAUDIO and VIDIOCSAUDIO ioctl and struct video_audio are used to enumerate the audio inputs of a V4L device. The equivalent V4L2 ioctls are VIDIOC_G_AUDIO and VIDIOC_S_AUDIO using struct v4l2_audio as discussed in Audio.
The audio "channel number" field counting audio inputs was renamed to index.
On VIDIOCSAUDIO the mode field selects one of the VIDEO_SOUND_MONO, VIDEO_SOUND_STEREO, VIDEO_SOUND_LANG1 or VIDEO_SOUND_LANG2 audio demodulation modes. When the current audio standard is BTSC VIDEO_SOUND_LANG2 refers to SAP and VIDEO_SOUND_LANG1 is meaningless. Also undocumented in the V4L specification, there is no way to query the selected mode. On VIDIOCGAUDIO the driver returns the actually received audio programmes in this field. In the V4L2 API this information is stored in the struct v4l2_tuner rxsubchans and audmode fields, respectively. See tuner for more information on tuners. Related to audio modes struct v4l2_audio also reports if this is a mono or stereo input, regardless if the source is a tuner.
The following fields where replaced by V4L2 controls accessible with the ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU, VIDIOC_G_CTRL and VIDIOC_S_CTRL ioctls:
|
struct |
V4L2 Control ID |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
To determine which of these controls are supported by a driver V4L provides the flags VIDEO_AUDIO_VOLUME, VIDEO_AUDIO_BASS, VIDEO_AUDIO_TREBLE and VIDEO_AUDIO_BALANCE. In the V4L2 API the ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU ioctl reports if the respective control is supported. Accordingly the VIDEO_AUDIO_MUTABLE and VIDEO_AUDIO_MUTE flags where replaced by the boolean V4L2_CID_AUDIO_MUTE control.
All V4L2 controls have a step attribute replacing the struct video_audio step field. The V4L audio controls are assumed to range from 0 to 65535 with no particular reset value. The V4L2 API permits arbitrary limits and defaults which can be queried with the ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU ioctl. For general information about controls see control.
Frame Buffer Overlay #
The V4L2 ioctls equivalent to VIDIOCGFBUF and VIDIOCSFBUF are VIDIOC_G_FBUF and VIDIOC_S_FBUF. The base field of struct video_buffer remained unchanged, except V4L2 defines a flag to indicate non-destructive overlays instead of a NULL pointer. All other fields moved into the struct v4l2_pix_format fmt substructure of struct v4l2_framebuffer. The depth field was replaced by pixelformat. See RGB Formats for a list of RGB formats and their respective color depths.
Instead of the special ioctls VIDIOCGWIN and VIDIOCSWIN V4L2 uses the general-purpose data format negotiation ioctls VIDIOC_G_FMT and VIDIOC_S_FMT. They take a pointer to a struct v4l2_format as argument. Here the win member of the fmt union is used, a struct v4l2_window.
The x, y, width and height fields of struct video_window moved into struct v4l2_rect substructure w of struct v4l2_window. The chromakey, clips, and clipcount fields remained unchanged. Struct video_clip was renamed to struct v4l2_clip, also containing a struct v4l2_rect, but the semantics are still the same.
The VIDEO_WINDOW_INTERLACE flag was dropped. Instead applications must set the field field to V4L2_FIELD_ANY or V4L2_FIELD_INTERLACED. The VIDEO_WINDOW_CHROMAKEY flag moved into struct v4l2_framebuffer, under the new name V4L2_FBUF_FLAG_CHROMAKEY.
In V4L, storing a bitmap pointer in clips and setting clipcount to VIDEO_CLIP_BITMAP (-1) requests bitmap clipping, using a fixed size bitmap of 1024 × 625 bits. Struct v4l2_window has a separate bitmap pointer field for this purpose and the bitmap size is determined by w.width and w.height.
The VIDIOCCAPTURE ioctl to enable or disable overlay was renamed to vidioc_overlay.
Cropping #
To capture only a subsection of the full picture V4L defines the VIDIOCGCAPTURE and VIDIOCSCAPTURE ioctls using struct video_capture. The equivalent V4L2 ioctls are VIDIOC_G_CROP and VIDIOC_S_CROP using struct v4l2_crop, and the related vidioc_cropcap ioctl. This is a rather complex matter, see crop for details.
The x, y, width and height fields moved into struct v4l2_rect substructure c of struct v4l2_crop. The decimation field was dropped. In the V4L2 API the scaling factor is implied by the size of the cropping rectangle and the size of the captured or overlaid image.
The VIDEO_CAPTURE_ODD and VIDEO_CAPTURE_EVEN flags to capture only the odd or even field, respectively, were replaced by V4L2_FIELD_TOP and V4L2_FIELD_BOTTOM in the field named field of struct v4l2_pix_format and struct v4l2_window. These structures are used to select a capture or overlay format with the VIDIOC_S_FMT ioctl.
Reading Images, Memory Mapping #
Capturing using the read method #
There is no essential difference between reading images from a V4L or V4L2 device using the read() function, however V4L2 drivers are not required to support this I/O method. Applications can determine if the function is available with the vidioc_querycap ioctl. All V4L2 devices exchanging data with applications must support the select() and poll() functions.
To select an image format and size, V4L provides the VIDIOCSPICT and VIDIOCSWIN ioctls. V4L2 uses the general-purpose data format negotiation ioctls VIDIOC_G_FMT and VIDIOC_S_FMT. They take a pointer to a struct v4l2_format as argument, here the struct v4l2_pix_format named pix of its fmt union is used.
For more information about the V4L2 read interface see rw.
Capturing using memory mapping #
Applications can read from V4L devices by mapping buffers in device memory, or more often just buffers allocated in DMA-able system memory, into their address space. This avoids the data copying overhead of the read method. V4L2 supports memory mapping as well, with a few differences.
|
V4L |
V4L2 |
|---|---|
|
The image format must be selected before buffers are allocated, with the VIDIOC_S_FMT ioctl. When no format is selected the driver may use the last, possibly by another application requested format. |
|
|
Applications cannot change the number of buffers. The it is built into the driver, unless it has a module option to change the number when the driver module is loaded. |
The ioctl VIDIOC_REQBUFS ioctl allocates the desired number of buffers, this is a required step in the initialization sequence. |
|
Drivers map all buffers as one contiguous range of memory. The |
Buffers are individually mapped. The offset and size of each buffer can be determined with the vidioc_querybuf ioctl. |
|
The The |
Drivers maintain an incoming and outgoing queue. vidioc_qbuf enqueues any empty buffer into the incoming queue. Filled buffers are dequeued from the outgoing queue with the VIDIOC_DQBUF ioctl. To wait until filled buffers become available this function, |
For a more in-depth discussion of memory mapping and examples, see mmap.
Reading Raw VBI Data #
Originally the V4L API did not specify a raw VBI capture interface, only the device file /dev/vbi was reserved for this purpose. The only driver supporting this interface was the BTTV driver, de-facto defining the V4L VBI interface. Reading from the device yields a raw VBI image with the following parameters:
|
struct |
V4L, BTTV driver |
|---|---|
|
sampling_rate |
28636363 Hz NTSC (or any other 525-line standard); 35468950 Hz PAL and SECAM (625-line standards) |
|
offset |
? |
|
samples_per_line |
2048 |
|
sample_format |
V4L2_PIX_FMT_GREY. The last four bytes (a machine endianness integer) contain a frame counter. |
|
start[] |
10, 273 NTSC; 22, 335 PAL and SECAM |
|
count[] |
16, 16 9 |
|
flags |
0 |
Undocumented in the V4L specification, in Linux 2.3 the VIDIOCGVBIFMT and VIDIOCSVBIFMT ioctls using struct vbi_format were added to determine the VBI image parameters. These ioctls are only partially compatible with the V4L2 VBI interface specified in raw-vbi.
An offset field does not exist, sample_format is supposed to be VIDEO_PALETTE_RAW, equivalent to V4L2_PIX_FMT_GREY. The remaining fields are probably equivalent to struct v4l2_vbi_format.
Apparently only the Zoran (ZR 36120) driver implements these ioctls. The semantics differ from those specified for V4L2 in two ways. The parameters are reset on open() and VIDIOCSVBIFMT always returns an EINVAL error code if the parameters are invalid.
Miscellaneous #
V4L2 has no equivalent of the VIDIOCGUNIT ioctl. Applications can find the VBI device associated with a video capture device (or vice versa) by reopening the device and requesting VBI data. For details see open.
No replacement exists for VIDIOCKEY, and the V4L functions for microcode programming. A new interface for MPEG compression and playback devices is documented in extended-controls.
[1] According to Documentation/admin-guide/devices.rst these should be symbolic links to /dev/video0. Note the original bttv interface is not compatible with V4L or V4L2.
[2] According to Documentation/admin-guide/devices.rst a symbolic link to /dev/radio0.
[3] This is a custom format used by the BTTV driver, not one of the V4L2 standard formats.
[4] Presumably all V4L RGB formats are little-endian, although some drivers might interpret them according to machine endianness. V4L2 defines little-endian, big-endian and red/blue swapped variants. For details see RGB Formats.
[5] VIDEO_PALETTE_YUV422 and VIDEO_PALETTE_YUYV are the same formats. Some V4L drivers respond to one, some to the other.
[6] Not to be confused with V4L2_PIX_FMT_YUV411P, which is a planar format.
[7] V4L explains this as: "RAW capture (BT848)"
[8] Not to be confused with V4L2_PIX_FMT_Y41P, which is a packed format.
[9] Old driver versions used different values, eventually the custom BTTV_VBISIZE ioctl was added to query the correct values.
Streaming I/O (DMA buffer importing)
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The DMABUF framework provides a generic method for sharing buffers between multiple devices. Device drivers that support DMABUF can export a DMA buffer to userspace as a file descriptor (known as the exporter role), import a DMA buffer from userspace using a file descriptor previously exported for a different or the same device (known as the importer role), or both. This section describes the DMABUF importer role API in V4L2.
Refer to DMABUF exporting for details about exporting V4L2 buffers as DMABUF file descriptors.
Input and output devices support the streaming I/O method when the V4L2_CAP_STREAMING flag in the capabilities field of struct v4l2_capability returned by the VIDIOC_QUERYCAP ioctl is set. Whether importing DMA buffers through DMABUF file descriptors is supported is determined by calling the VIDIOC_REQBUFS ioctl with the memory type set to V4L2_MEMORY_DMABUF.
This I/O method is dedicated to sharing DMA buffers between different devices, which may be V4L devices or other video-related devices (e.g. DRM). Buffers (planes) are allocated by a driver on behalf of an application. Next, these buffers are exported to the application as file descriptors using an API which is specific for an allocator driver. Only such file descriptor are exchanged. The descriptors and meta-information are passed in struct v4l2_buffer (or in struct v4l2_plane in the multi-planar API case). The driver must be switched into DMABUF I/O mode by calling the VIDIOC_REQBUFS with the desired buffer type.
Example: Initiating streaming I/O with DMABUF file descriptors #
struct v4l2_requestbuffers reqbuf;
;
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
reqbuf.memory = V4L2_MEMORY_DMABUF;
reqbuf.count = 1;
if
The buffer (plane) file descriptor is passed on the fly with the VIDIOC_QBUF ioctl. In case of multiplanar buffers, every plane can be associated with a different DMABUF descriptor. Although buffers are commonly cycled, applications can pass a different DMABUF descriptor at each VIDIOC_QBUF call.
Example: Queueing DMABUF using single plane API #
int
Example 3.6. Queueing DMABUF using multi plane API #
int
Captured or displayed buffers are dequeued with the VIDIOC_DQBUF ioctl. The driver can unlock the buffer at any time between the completion of the DMA and this ioctl. The memory is also unlocked when VIDIOC_STREAMOFF is called, VIDIOC_REQBUFS, or when the device is closed.
For capturing applications it is customary to enqueue a number of empty buffers, to start capturing and enter the read loop. Here the application waits until a filled buffer can be dequeued, and re-enqueues the buffer when the data is no longer needed. Output applications fill and enqueue buffers, when enough buffers are stacked up output is started. In the write loop, when the application runs out of free buffers it must wait until an empty buffer can be dequeued and reused. Two methods exist to suspend execution of the application until one or more buffers can be dequeued. By default VIDIOC_DQBUF blocks when no buffer is in the outgoing queue. When the O_NONBLOCK flag was given to the open() function, VIDIOC_DQBUF returns immediately with an EAGAIN error code when no buffer is available. The select() and poll() functions are always available.
To start and stop capturing or displaying applications call the VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctls.
Drivers implementing DMABUF importing I/O must support the VIDIOC_REQBUFS, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctls, and the select() and poll() functions.
Digital Video (DV) Timings
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The video standards discussed so far have been dealing with Analog TV and the corresponding video timings. Today there are many more different hardware interfaces such as High Definition TV interfaces (HDMI), VGA, DVI connectors etc., that carry video signals and there is a need to extend the API to select the video timings for these interfaces. Since it is not possible to extend the v4l2_std_id due to the limited bits available, a new set of ioctls was added to set/get video timings at the input and output.
These ioctls deal with the detailed digital video timings that define each video format. This includes parameters such as the active video width and height, signal polarities, frontporches, backporches, sync widths etc. The linux/v4l2-dv-timings.h header can be used to get the timings of the formats in the CEA-861-E and VESA DMT standards.
To enumerate and query the attributes of the DV timings supported by a device applications use the ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS and ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP ioctls. To set DV timings for the device applications use the VIDIOC_S_DV_TIMINGS ioctl and to get current DV timings they use the VIDIOC_G_DV_TIMINGS ioctl. To detect the DV timings as seen by the video receiver applications use the ioctl VIDIOC_QUERY_DV_TIMINGS ioctl.
When the hardware detects a video source change (e.g. the video signal appears or disappears, or the video resolution changes), then it will issue a V4L2_EVENT_SOURCE_CHANGE event. Use the ioctl VIDIOC_SUBSCRIBE_EVENT and the ioctl VIDIOC_DQEVENT to check if this event was reported.
If the video signal changed, then the application has to stop streaming, free all buffers, and call the ioctl VIDIOC_QUERY_DV_TIMINGS to obtain the new video timings, and if they are valid, it can set those by calling the ioctl VIDIOC_S_DV_TIMINGS. This will also update the format, so use the ioctl VIDIOC_G_FMT to obtain the new format. Now the application can allocate new buffers and start streaming again.
The ioctl VIDIOC_QUERY_DV_TIMINGS will just report what the hardware detects, it will never change the configuration. If the currently set timings and the actually detected timings differ, then typically this will mean that you will not be able to capture any video. The correct approach is to rely on the V4L2_EVENT_SOURCE_CHANGE event so you know when something changed.
Applications can make use of the input-capabilities and output-capabilities flags to determine whether the digital video ioctls can be used with the given input or output.
Camera Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Camera class includes controls for mechanical (or equivalent digital) features of a device such as controllable lenses or sensors.
Camera Control IDs #
-
V4L2_CID_CAMERA_CLASS (class)The Camera class descriptor. Calling ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU for this control will return a description of this control class.
-
V4L2_CID_EXPOSURE_AUTO(enum)
-
enum v4l2_exposure_auto_type -
Enables automatic adjustments of the exposure time and/or iris aperture. The effect of manual changes of the exposure time or iris aperture while these features are enabled is undefined, drivers should ignore such requests. Possible values are:
|
|
Automatic exposure time, automatic iris aperture. |
|
|
Manual exposure time, manual iris. |
|
|
Manual exposure time, auto iris. |
|
|
Auto exposure time, manual iris. |
-
V4L2_CID_EXPOSURE_ABSOLUTE (integer)Determines the exposure time of the camera sensor. The exposure time is limited by the frame interval. Drivers should interpret the values as 100 µs units, where the value 1 stands for 1/10000th of a second, 10000 for 1 second and 100000 for 10 seconds.
-
V4L2_CID_EXPOSURE_AUTO_PRIORITY (boolean)When
V4L2_CID_EXPOSURE_AUTOis set toAUTOorAPERTURE_PRIORITY, this control determines if the device may dynamically vary the frame rate. By default this feature is disabled (0) and the frame rate must remain constant. -
V4L2_CID_AUTO_EXPOSURE_BIAS (integer menu)Determines the automatic exposure compensation, it is effective only when
V4L2_CID_EXPOSURE_AUTOcontrol is set toAUTO,SHUTTER_PRIORITYorAPERTURE_PRIORITY. It is expressed in terms of EV, drivers should interpret the values as 0.001 EV units, where the value 1000 stands for +1 EV.Increasing the exposure compensation value is equivalent to decreasing the exposure value (EV) and will increase the amount of light at the image sensor. The camera performs the exposure compensation by adjusting absolute exposure time and/or aperture.
-
V4L2_CID_EXPOSURE_METERING(enum)
-
enum v4l2_exposure_metering -
Determines how the camera measures the amount of light available for the frame exposure. Possible values are:
|
|
Use the light information coming from the entire frame and average giving no weighting to any particular portion of the metered area. |
|
|
Average the light information coming from the entire frame giving priority to the center of the metered area. |
|
|
Measure only very small area at the center of the frame. |
|
|
A multi-zone metering. The light intensity is measured in several points of the frame and the results are combined. The algorithm of the zones selection and their significance in calculating the final value is device dependent. |
-
V4L2_CID_PAN_RELATIVE (integer)This control turns the camera horizontally by the specified amount. The unit is undefined. A positive value moves the camera to the right (clockwise when viewed from above), a negative value to the left. A value of zero does not cause motion. This is a write-only control.
-
V4L2_CID_TILT_RELATIVE (integer)This control turns the camera vertically by the specified amount. The unit is undefined. A positive value moves the camera up, a negative value down. A value of zero does not cause motion. This is a write-only control.
-
V4L2_CID_PAN_RESET (button)When this control is set, the camera moves horizontally to the default position.
-
V4L2_CID_TILT_RESET (button)When this control is set, the camera moves vertically to the default position.
-
V4L2_CID_PAN_ABSOLUTE (integer)This control turns the camera horizontally to the specified position. Positive values move the camera to the right (clockwise when viewed from above), negative values to the left. Drivers should interpret the values as arc seconds, with valid values between -180 * 3600 and +180 * 3600 inclusive.
-
V4L2_CID_TILT_ABSOLUTE (integer)This control turns the camera vertically to the specified position. Positive values move the camera up, negative values down. Drivers should interpret the values as arc seconds, with valid values between -180 * 3600 and +180 * 3600 inclusive.
-
V4L2_CID_FOCUS_ABSOLUTE (integer)This control sets the focal point of the camera to the specified position. The unit is undefined. Positive values set the focus closer to the camera, negative values towards infinity.
-
V4L2_CID_FOCUS_RELATIVE (integer)This control moves the focal point of the camera by the specified amount. The unit is undefined. Positive values move the focus closer to the camera, negative values towards infinity. This is a write-only control.
-
V4L2_CID_FOCUS_AUTO (boolean)Enables continuous automatic focus adjustments. The effect of manual focus adjustments while this feature is enabled is undefined, drivers should ignore such requests.
-
V4L2_CID_AUTO_FOCUS_START (button)Starts single auto focus process. The effect of setting this control when
V4L2_CID_FOCUS_AUTOis set toTRUE(1) is undefined, drivers should ignore such requests. -
V4L2_CID_AUTO_FOCUS_STOP (button)Aborts automatic focusing started with
V4L2_CID_AUTO_FOCUS_STARTcontrol. It is effective only when the continuous autofocus is disabled, that is whenV4L2_CID_FOCUS_AUTOcontrol is set toFALSE(0).
-
V4L2_CID_AUTO_FOCUS_STATUS (bitmask)The automatic focus status. This is a read-only control.
Setting
V4L2_LOCK_FOCUSlock bit of theV4L2_CID_3A_LOCKcontrol may stop updates of theV4L2_CID_AUTO_FOCUS_STATUScontrol value.
|
|
Automatic focus is not active. |
|
|
Automatic focusing is in progress. |
|
|
Focus has been reached. |
|
|
Automatic focus has failed, the driver will not transition from this state until another action is performed by an application. |
-
V4L2_CID_AUTO_FOCUS_RANGE(enum)
-
enum v4l2_auto_focus_range -
Determines auto focus distance range for which lens may be adjusted.
|
|
The camera automatically selects the focus range. |
|
|
Normal distance range, limited for best automatic focus performance. |
|
|
Macro (close-up) auto focus. The camera will use its minimum possible distance for auto focus. |
|
|
The lens is set to focus on an object at infinite distance. |
-
V4L2_CID_ZOOM_ABSOLUTE (integer)Specify the objective lens focal length as an absolute value. The zoom unit is driver-specific and its value should be a positive integer.
-
V4L2_CID_ZOOM_RELATIVE (integer)Specify the objective lens focal length relatively to the current value. Positive values move the zoom lens group towards the telephoto direction, negative values towards the wide-angle direction. The zoom unit is driver-specific. This is a write-only control.
-
V4L2_CID_ZOOM_CONTINUOUS (integer)Move the objective lens group at the specified speed until it reaches physical device limits or until an explicit request to stop the movement. A positive value moves the zoom lens group towards the telephoto direction. A value of zero stops the zoom lens group movement. A negative value moves the zoom lens group towards the wide-angle direction. The zoom speed unit is driver-specific.
-
V4L2_CID_IRIS_ABSOLUTE (integer)This control sets the camera's aperture to the specified value. The unit is undefined. Larger values open the iris wider, smaller values close it.
-
V4L2_CID_IRIS_RELATIVE (integer)This control modifies the camera's aperture by the specified amount. The unit is undefined. Positive values open the iris one step further, negative values close it one step further. This is a write-only control.
-
V4L2_CID_PRIVACY (boolean)Prevent video from being acquired by the camera. When this control is set to
TRUE(1), no image can be captured by the camera. Common means to enforce privacy are mechanical obturation of the sensor and firmware image processing, but the device is not restricted to these methods. Devices that implement the privacy control must support read access and may support write access. -
V4L2_CID_BAND_STOP_FILTER (integer)Switch the band-stop filter of a camera sensor on or off, or specify its strength. Such band-stop filters can be used, for example, to filter out the fluorescent light component.
-
V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE(enum)
-
enum v4l2_auto_n_preset_white_balance -
Sets white balance to automatic, manual or a preset. The presets determine color temperature of the light as a hint to the camera for white balance adjustments resulting in most accurate color representation. The following white balance presets are listed in order of increasing color temperature.
|
|
Manual white balance. |
|
|
Automatic white balance adjustments. |
|
|
White balance setting for incandescent (tungsten) lighting. It generally cools down the colors and corresponds approximately to 2500...3500 K color temperature range. |
|
|
White balance preset for fluorescent lighting. It corresponds approximately to 4000...5000 K color temperature. |
|
|
With this setting the camera will compensate for fluorescent H lighting. |
|
|
White balance setting for horizon daylight. It corresponds approximately to 5000 K color temperature. |
|
|
White balance preset for daylight (with clear sky). It corresponds approximately to 5000...6500 K color temperature. |
|
|
With this setting the camera will compensate for the flash light. It slightly warms up the colors and corresponds roughly to 5000...5500 K color temperature. |
|
|
White balance preset for moderately overcast sky. This option corresponds approximately to 6500...8000 K color temperature range. |
|
|
White balance preset for shade or heavily overcast sky. It corresponds approximately to 9000...10000 K color temperature. |
-
V4L2_CID_WIDE_DYNAMIC_RANGE (boolean)Enables or disables the camera's wide dynamic range feature. This feature allows to obtain clear images in situations where intensity of the illumination varies significantly throughout the scene, i.e. there are simultaneously very dark and very bright areas. It is most commonly realized in cameras by combining two subsequent frames with different exposure times. 1
-
V4L2_CID_IMAGE_STABILIZATION (boolean)Enables or disables image stabilization.
-
V4L2_CID_ISO_SENSITIVITY (integer menu)Determines ISO equivalent of an image sensor indicating the sensor's sensitivity to light. The numbers are expressed in arithmetic scale, as per iso12232 standard, where doubling the sensor sensitivity is represented by doubling the numerical ISO value. Applications should interpret the values as standard ISO values multiplied by 1000, e.g. control value 800 stands for ISO 0.8. Drivers will usually support only a subset of standard ISO values. The effect of setting this control while the
V4L2_CID_ISO_SENSITIVITY_AUTOcontrol is set to a value other thanV4L2_CID_ISO_SENSITIVITY_MANUALis undefined, drivers should ignore such requests.
-
V4L2_CID_ISO_SENSITIVITY_AUTO(enum)
-
enum v4l2_iso_sensitivity_type -
Enables or disables automatic ISO sensitivity adjustments.
|
|
Manual ISO sensitivity. |
|
|
Automatic ISO sensitivity adjustments. |
-
V4L2_CID_SCENE_MODE(enum)
-
enum v4l2_scene_mode -
This control allows to select scene programs as the camera automatic modes optimized for common shooting scenes. Within these modes the camera determines best exposure, aperture, focusing, light metering, white balance and equivalent sensitivity. The controls of those parameters are influenced by the scene mode control. An exact behavior in each mode is subject to the camera specification.
When the scene mode feature is not used, this control should be set to
V4L2_SCENE_MODE_NONEto make sure the other possibly related controls are accessible. The following scene programs are defined:
|
|
The scene mode feature is disabled. |
|
|
Backlight. Compensates for dark shadows when light is coming from behind a subject, also by automatically turning on the flash. |
|
|
Beach and snow. This mode compensates for all-white or bright scenes, which tend to look gray and low contrast, when camera's automatic exposure is based on an average scene brightness. To compensate, this mode automatically slightly overexposes the frames. The white balance may also be adjusted to compensate for the fact that reflected snow looks bluish rather than white. |
|
|
Candle light. The camera generally raises the ISO sensitivity and lowers the shutter speed. This mode compensates for relatively close subject in the scene. The flash is disabled in order to preserve the ambiance of the light. |
|
|
Dawn and dusk. Preserves the colors seen in low natural light before dusk and after down. The camera may turn off the flash, and automatically focus at infinity. It will usually boost saturation and lower the shutter speed. |
|
|
Fall colors. Increases saturation and adjusts white balance for color enhancement. Pictures of autumn leaves get saturated reds and yellows. |
|
|
Fireworks. Long exposure times are used to capture the expanding burst of light from a firework. The camera may invoke image stabilization. |
|
|
Landscape. The camera may choose a small aperture to provide deep depth of field and long exposure duration to help capture detail in dim light conditions. The focus is fixed at infinity. Suitable for distant and wide scenery. |
|
|
Night, also known as Night Landscape. Designed for low light conditions, it preserves detail in the dark areas without blowing out bright objects. The camera generally sets itself to a medium-to-high ISO sensitivity, with a relatively long exposure time, and turns flash off. As such, there will be increased image noise and the possibility of blurred image. |
|
|
Party and indoor. Designed to capture indoor scenes that are lit by indoor background lighting as well as the flash. The camera usually increases ISO sensitivity, and adjusts exposure for the low light conditions. |
|
|
Portrait. The camera adjusts the aperture so that the depth of field is reduced, which helps to isolate the subject against a smooth background. Most cameras recognize the presence of faces in the scene and focus on them. The color hue is adjusted to enhance skin tones. The intensity of the flash is often reduced. |
|
|
Sports. Significantly increases ISO and uses a fast shutter speed to freeze motion of rapidly-moving subjects. Increased image noise may be seen in this mode. |
|
|
Sunset. Preserves deep hues seen in sunsets and sunrises. It bumps up the saturation. |
|
|
Text. It applies extra contrast and sharpness, it is typically a black-and-white mode optimized for readability. Automatic focus may be switched to close-up mode and this setting may also involve some lens-distortion correction. |
-
V4L2_CID_3A_LOCK (bitmask)This control locks or unlocks the automatic focus, exposure and white balance. The automatic adjustments can be paused independently by setting the corresponding lock bit to 1. The camera then retains the settings until the lock bit is cleared. The following lock bits are defined:
When a given algorithm is not enabled, drivers should ignore requests to lock it and should return no error. An example might be an application setting bit
V4L2_LOCK_WHITE_BALANCEwhen theV4L2_CID_AUTO_WHITE_BALANCEcontrol is set toFALSE. The value of this control may be changed by exposure, white balance or focus controls.
|
|
Automatic exposure adjustments lock. |
|
|
Automatic white balance adjustments lock. |
|
|
Automatic focus lock. |
-
V4L2_CID_PAN_SPEED (integer)This control turns the camera horizontally at the specific speed. The unit is undefined. A positive value moves the camera to the right (clockwise when viewed from above), a negative value to the left. A value of zero stops the motion if one is in progress and has no effect otherwise.
-
V4L2_CID_TILT_SPEED (integer)This control turns the camera vertically at the specified speed. The unit is undefined. A positive value moves the camera up, a negative value down. A value of zero stops the motion if one is in progress and has no effect otherwise.
-
V4L2_CID_CAMERA_ORIENTATION (menu)This read-only control describes the camera orientation by reporting its mounting position on the device where the camera is installed. The control value is constant and not modifiable by software. This control is particularly meaningful for devices which have a well defined orientation, such as phones, laptops and portable devices since the control is expressed as a position relative to the device's intended usage orientation. For example, a camera installed on the user-facing side of a phone, a tablet or a laptop device is said to be have
V4L2_CAMERA_ORIENTATION_FRONTorientation, while a camera installed on the opposite side of the front one is said to be haveV4L2_CAMERA_ORIENTATION_BACKorientation. Camera sensors not directly attached to the device, or attached in a way that allows them to move freely, such as webcams and digital cameras, are said to have theV4L2_CAMERA_ORIENTATION_EXTERNALorientation.
|
|
The camera is oriented towards the user facing side of the device. |
|
|
The camera is oriented towards the back facing side of the device. |
|
|
The camera is not directly attached to the device and is freely movable. |
-
V4L2_CID_CAMERA_SENSOR_ROTATION (integer)This read-only control describes the rotation correction in degrees in the counter-clockwise direction to be applied to the captured images once captured to memory to compensate for the camera sensor mounting rotation.
For a precise definition of the sensor mounting rotation refer to the extensive description of the 'rotation' properties in the device tree bindings file 'video-interfaces.txt'.
A few examples are below reported, using a shark swimming from left to right in front of the user as the example scene to capture.
0 X-axis 0 +-------------------------------------> ! ! ! ! |\____)\___ ! ) _____ __`< ! |/ )/ ! ! ! V Y-axisExample one - Webcam
Assuming you can bring your laptop with you while swimming with sharks, the camera module of the laptop is installed on the user facing part of a laptop screen casing, and is typically used for video calls. The captured images are meant to be displayed in landscape mode (width > height) on the laptop screen.
The camera is typically mounted upside-down to compensate the lens optical inversion effect. In this case the value of the V4L2_CID_CAMERA_SENSOR_ROTATION control is 0, no rotation is required to display images correctly to the user.
If the camera sensor is not mounted upside-down it is required to compensate the lens optical inversion effect and the value of the V4L2_CID_CAMERA_SENSOR_ROTATION control is 180 degrees, as images will result rotated when captured to memory.
+--------------------------------------+ ! ! ! ! ! ! ! __/(_____/| ! ! >.___ ____ ( ! ! \( \| ! ! ! ! ! ! ! +--------------------------------------+A software rotation correction of 180 degrees has to be applied to correctly display the image on the user screen.
+--------------------------------------+ ! ! ! ! ! ! ! |\____)\___ ! ! ) _____ __`< ! ! |/ )/ ! ! ! ! ! ! ! +--------------------------------------+Example two - Phone camera
It is more handy to go and swim with sharks with only your mobile phone with you and take pictures with the camera that is installed on the back side of the device, facing away from the user. The captured images are meant to be displayed in portrait mode (height > width) to match the device screen orientation and the device usage orientation used when taking the picture.
The camera sensor is typically mounted with its pixel array longer side aligned to the device longer side, upside-down mounted to compensate for the lens optical inversion effect.
The images once captured to memory will be rotated and the value of the V4L2_CID_CAMERA_SENSOR_ROTATION will report a 90 degree rotation.
+-------------------------------------+ | _ _ | | \ / | | | | | | | | | | | > | | < | | | | | | | . | | V | +-------------------------------------+A correction of 90 degrees in counter-clockwise direction has to be applied to correctly display the image in portrait mode on the device screen.
+--------------------+ | | | | | | | | | | | | | |\____)\___ | | ) _____ __`< | | |/ )/ | | | | | | | | | | | +--------------------+
[1] This control may be changed to a menu control in the future, if more options are required.
-
V4L2_CID_HDR_SENSOR_MODE (menu)Change the sensor HDR mode. A HDR picture is obtained by merging two captures of the same scene using two different exposure periods. HDR mode describes the way these two captures are merged in the sensor.
As modes differ for each sensor, menu items are not standardized by this control and are left to the programmer.
Stateless Codec Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Stateless Codec control class is intended to support stateless decoder and encoders (i.e. hardware accelerators).
These drivers are typically supported by the stateless_decoder, and deal with parsed pixel formats such as V4L2_PIX_FMT_H264_SLICE.
Stateless Codec Control ID #
-
V4L2_CID_CODEC_STATELESS_CLASS (class)The Stateless Codec class descriptor.
-
V4L2_CID_STATELESS_H264_SPS (struct)Specifies the sequence parameter set (as extracted from the bitstream) for the associated H264 slice data. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for H264. The bitstream parameters are defined according to h264, section 7.4.2.1.1 "Sequence Parameter Set Data Semantics". For further documentation, refer to the above specification, unless there is an explicit comment stating otherwise.
v4l2_ctrl_h264_sps
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__s32 |
|
|
|
__s32 |
|
|
|
__s32 |
|
|
|
__u16 |
|
|
|
__u16 |
|
|
|
__u32 |
|
Sequence Parameter Set Constraints Set Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
|
|
|
0x00000004 |
|
|
|
0x00000008 |
|
|
|
0x00000010 |
|
|
|
0x00000020 |
Sequence Parameter Set Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
|
|
|
0x00000004 |
|
|
|
0x00000008 |
|
|
|
0x00000010 |
|
|
|
0x00000020 |
|
|
|
0x00000040 |
-
V4L2_CID_STATELESS_H264_PPS (struct)Specifies the picture parameter set (as extracted from the bitstream) for the associated H264 slice data. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for H264. The bitstream parameters are defined according to h264, section 7.4.2.2 "Picture Parameter Set RBSP Semantics". For further documentation, refer to the above specification, unless there is an explicit comment stating otherwise.
v4l2_ctrl_h264_pps
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__s8 |
|
|
|
__s8 |
|
|
|
__s8 |
|
|
|
__s8 |
|
|
|
__u16 |
|
Picture Parameter Set Flags
|
|
0x0001 |
|
|
|
0x0002 |
|
|
|
0x0004 |
|
|
|
0x0008 |
|
|
|
0x0010 |
|
|
|
0x0020 |
|
|
|
0x0040 |
|
|
|
0x0080 |
|
-
V4L2_CID_STATELESS_H264_SCALING_MATRIX (struct)Specifies the scaling matrix (as extracted from the bitstream) for the associated H264 slice data. The bitstream parameters are defined according to h264, section 7.4.2.1.1.1 "Scaling List Semantics". For further documentation, refer to the above specification, unless there is an explicit comment stating otherwise.
v4l2_ctrl_h264_scaling_matrix
|
__u8 |
|
Scaling matrix after applying the inverse scanning process. Expected list order is Intra Y, Intra Cb, Intra Cr, Inter Y, Inter Cb, Inter Cr. The values on each scaling list are expected in raster scan order. |
|
__u8 |
|
Scaling matrix after applying the inverse scanning process. Expected list order is Intra Y, Inter Y, Intra Cb, Inter Cb, Intra Cr, Inter Cr. The values on each scaling list are expected in raster scan order. |
-
V4L2_CID_STATELESS_H264_SLICE_PARAMS (struct)Specifies the slice parameters (as extracted from the bitstream) for the associated H264 slice data. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for H264. The bitstream parameters are defined according to h264, section 7.4.3 "Slice Header Semantics". For further documentation, refer to the above specification, unless there is an explicit comment stating otherwise.
v4l2_ctrl_h264_slice_params
|
__u32 |
|
Offset in bits to slice_data() from the beginning of this slice. |
|
__u32 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__u8 |
|
|
|
__s8 |
|
|
|
__s8 |
|
|
|
__u8 |
|
|
|
__s8 |
|
|
|
__s8 |
|
|
|
__u8 |
|
If num_ref_idx_active_override_flag is not set, this field must be set to the value of num_ref_idx_l0_default_active_minus1 |
|
__u8 |
|
If num_ref_idx_active_override_flag is not set, this field must be set to the value of num_ref_idx_l1_default_active_minus1 |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
struct |
|
Reference picture list after applying the per-slice modifications |
|
struct |
|
Reference picture list after applying the per-slice modifications |
|
__u32 |
|
Slice Parameter Set Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
-
V4L2_CID_STATELESS_H264_PRED_WEIGHTS (struct)Prediction weight table defined according to h264, section 7.4.3.2 "Prediction Weight Table Semantics". The prediction weight table must be passed by applications under the conditions explained in section 7.3.3 "Slice header syntax".
v4l2_ctrl_h264_pred_weights
|
__u16 |
|
|
|
__u16 |
|
|
|
struct |
|
The weight factors at index 0 are the weight factors for the reference list 0, the one at index 1 for the reference list 1. |
v4l2_h264_weight_factors
|
__s16 |
|
|
|
__s16 |
|
|
|
__s16 |
|
|
|
__s16 |
|
Picture Reference
v4l2_h264_reference
|
__u8 |
|
Specifies how the picture is referenced. See Reference Fields |
|
__u8 |
|
Index into the |
Reference Fields
|
|
0x1 |
The top field in field pair is used for short-term reference. |
|
|
0x2 |
The bottom field in field pair is used for short-term reference. |
|
|
0x3 |
The frame (or the top/bottom fields, if it's a field pair) is used for short-term reference. |
-
V4L2_CID_STATELESS_H264_DECODE_PARAMS (struct)Specifies the decode parameters (as extracted from the bitstream) for the associated H264 slice data. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for H264. The bitstream parameters are defined according to h264. For further documentation, refer to the above specification, unless there is an explicit comment stating otherwise.
v4l2_ctrl_h264_decode_params
|
struct |
|
|
|
__u16 |
|
NAL reference ID value coming from the NAL Unit header |
|
__u16 |
|
|
|
__s32 |
|
Picture Order Count for the coded top field |
|
__s32 |
|
Picture Order Count for the coded bottom field |
|
__u16 |
|
|
|
__u16 |
|
|
|
__s32 |
|
|
|
__s32 |
|
|
|
__s32 |
|
|
|
__u32 |
|
Size in bits of the dec_ref_pic_marking() syntax element. |
|
__u32 |
|
Combined size in bits of the picture order count related syntax elements: pic_order_cnt_lsb, delta_pic_order_cnt_bottom, delta_pic_order_cnt0, and delta_pic_order_cnt1. |
|
__u32 |
|
|
|
__u32 |
|
Applications and drivers must set this to zero. |
|
__u32 |
|
Decode Parameters Flags
|
|
0x00000001 |
That picture is an IDR picture |
|
|
0x00000002 |
|
|
|
0x00000004 |
|
|
|
0x00000008 |
|
|
|
0x00000010 |
v4l2_h264_dpb_entry
|
__u64 |
|
Timestamp of the V4L2 capture buffer to use as reference, used with B-coded and P-coded frames. The timestamp refers to the |
|
__u32 |
|
For short term references, this must match the derived value PicNum (8-28) and for long term references it must match the derived value LongTermPicNum (8-29). When decoding frames (as opposed to fields) pic_num is the same as FrameNumWrap. |
|
__u16 |
|
For short term references, this must match the frame_num value from the slice header syntax (the driver will wrap the value if needed). For long term references, this must be set to the value of long_term_frame_idx described in the dec_ref_pic_marking() syntax. |
|
__u8 |
|
Specifies how the DPB entry is referenced. See Reference Fields |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
__s32 |
|
|
|
__s32 |
|
|
|
__u32 |
|
See DPB Entry Flags |
DPB Entries Flags
|
|
0x00000001 |
The DPB entry is valid (non-empty) and should be considered. |
|
|
0x00000002 |
The DPB entry is used for reference. |
|
|
0x00000004 |
The DPB entry is used for long-term reference. |
|
|
0x00000008 |
The DPB entry is a single field or a complementary field pair. |
-
V4L2_CID_STATELESS_H264_DECODE_MODE (enum)Specifies the decoding mode to use. Currently exposes slice-based and frame-based decoding but new modes might be added later on. This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE are required to set this control in order to specify the decoding mode that is expected for the buffer. Drivers may expose a single or multiple decoding modes, depending on what they can support.
v4l2_stateless_h264_decode_mode
|
|
0 |
Decoding is done at the slice granularity. The OUTPUT buffer must contain a single slice. When this mode is selected, the |
|
|
1 |
Decoding is done at the frame granularity, The OUTPUT buffer must contain all slices needed to decode the frame. The OUTPUT buffer must also contain both fields. This mode will be supported by devices that parse the slice(s) header(s) in hardware. When this mode is selected, the |
-
V4L2_CID_STATELESS_H264_START_CODE (enum)Specifies the H264 slice start code expected for each slice. This control is used as a modifier for V4L2_PIX_FMT_H264_SLICE pixel format. Applications that support V4L2_PIX_FMT_H264_SLICE are required to set this control in order to specify the start code that is expected for the buffer. Drivers may expose a single or multiple start codes, depending on what they can support.
v4l2_stateless_h264_start_code
|
|
0 |
Selecting this value specifies that H264 slices are passed to the driver without any start code. The bitstream data should be according to h264 7.3.1 NAL unit syntax, hence contains emulation prevention bytes when required. |
|
|
1 |
Selecting this value specifies that H264 slices are expected to be prefixed by Annex B start codes. According to h264 valid start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001. |
-
V4L2_CID_STATELESS_FWHT_PARAMS (struct)Specifies the FWHT (Fast Walsh Hadamard Transform) parameters (as extracted from the bitstream) for the associated FWHT data. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for FWHT. This codec is specific to the vicodec test driver.
v4l2_ctrl_fwht_params
|
__u64 |
|
Timestamp of the V4L2 capture buffer to use as backward reference, used with P-coded frames. The timestamp refers to the |
|
__u32 |
|
The version of the codec. Set to |
|
__u32 |
|
The width of the frame. |
|
__u32 |
|
The height of the frame. |
|
__u32 |
|
The flags of the frame, see FWHT Flags. |
|
__u32 |
|
The colorspace of the frame, from enum |
|
__u32 |
|
The transfer function, from enum |
|
__u32 |
|
The Y'CbCr encoding, from enum |
|
__u32 |
|
The quantization range, from enum |
FWHT Flags #
|
|
0x00000001 |
Set if this is an interlaced format. |
|
|
0x00000002 |
Set if this is a bottom-first (NTSC) interlaced format. |
|
|
0x00000004 |
Set if each 'frame' contains just one field. |
|
|
0x00000008 |
If V4L2_FWHT_FL_IS_ALTERNATE was set, then this is set if this 'frame' is the bottom field, else it is the top field. |
|
|
0x00000010 |
Set if the Y' (luma) plane is uncompressed. |
|
|
0x00000020 |
Set if the Cb plane is uncompressed. |
|
|
0x00000040 |
Set if the Cr plane is uncompressed. |
|
|
0x00000080 |
Set if the chroma plane has the same height as the luma plane, else the chroma plane is half the height of the luma plane. |
|
|
0x00000100 |
Set if the chroma plane has the same width as the luma plane, else the chroma plane is half the width of the luma plane. |
|
|
0x00000200 |
Set if the alpha plane is uncompressed. |
|
|
0x00000400 |
Set if this is an I-frame. |
|
|
0x00070000 |
The number of color components minus one. |
|
|
0x00180000 |
The mask for the pixel encoding. |
|
|
0x00080000 |
Set if the pixel encoding is YUV. |
|
|
0x00100000 |
Set if the pixel encoding is RGB. |
|
|
0x00180000 |
Set if the pixel encoding is HSV. |
-
V4L2_CID_STATELESS_VP8_FRAME (struct)Specifies the frame parameters for the associated VP8 parsed frame data. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for VP8. The bitstream parameters are defined according to vp8.
v4l2_ctrl_vp8_frame
|
struct |
|
Structure with segment-based adjustments metadata. |
|
struct |
|
Structure with loop filter level adjustments metadata. |
|
struct |
|
Structure with VP8 dequantization indices metadata. |
|
struct |
|
Structure with VP8 entropy coder probabilities metadata. |
|
struct |
|
Structure with VP8 entropy coder state. |
|
__u16 |
|
The width of the frame. Must be set for all frames. |
|
__u16 |
|
The height of the frame. Must be set for all frames. |
|
__u8 |
|
Horizontal scaling factor. |
|
__u8 |
|
Vertical scaling factor. |
|
__u8 |
|
Bitstream version. |
|
__u8 |
|
Indicates the probability that the macroblock is not skipped. |
|
__u8 |
|
Indicates the probability that a macroblock is intra-predicted. |
|
__u8 |
|
Indicates the probability that the last reference frame is used for inter-prediction |
|
__u8 |
|
Indicates the probability that the golden reference frame is used for inter-prediction |
|
__u8 |
|
Number of DCT coefficients partitions. Must be one of: 1, 2, 4, or 8. |
|
__u32 |
|
Size of the first partition, i.e. the control partition. |
|
__u32 |
|
Size in bits of the first partition header portion. |
|
__u32 |
|
DCT coefficients sizes. |
|
__u64 |
|
Timestamp for the V4L2 capture buffer to use as last reference frame, used with inter-coded frames. The timestamp refers to the |
|
__u64 |
|
Timestamp for the V4L2 capture buffer to use as last reference frame, used with inter-coded frames. The timestamp refers to the |
|
__u64 |
|
Timestamp for the V4L2 capture buffer to use as alternate reference frame, used with inter-coded frames. The timestamp refers to the |
|
__u64 |
|
See Frame Flags |
Frame Flags
|
|
0x01 |
Indicates if the frame is a key frame. |
|
|
0x02 |
Experimental bitstream. |
|
|
0x04 |
Show frame flag, indicates if the frame is for display. |
|
|
0x08 |
Enable/disable skipping of macroblocks with no non-zero coefficients. |
|
|
0x10 |
Sign of motion vectors when the golden frame is referenced. |
|
|
0x20 |
Sign of motion vectors when the alt frame is referenced. |
v4l2_vp8_entropy_coder_state
|
__u8 |
|
coder state value for "Range" |
|
__u8 |
|
coder state value for "Value"- |
|
__u8 |
|
number of bits left. |
|
__u8 |
|
Applications and drivers must set this to zero. |
v4l2_vp8_segment
|
__s8 |
|
Signed quantizer value update. |
|
__s8 |
|
Signed loop filter level value update. |
|
__u8 |
|
Segment probabilities. |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
__u32 |
|
See Segment Flags |
Segment Flags
|
|
0x01 |
Enable/disable segment-based adjustments. |
|
|
0x02 |
Indicates if the macroblock segmentation map is updated in this frame. |
|
|
0x04 |
Indicates if the segment feature data is updated in this frame. |
|
|
0x08 |
If is set, the segment feature data mode is delta-value. If cleared, it's absolute-value. |
v4l2_vp8_loop_filter
|
__s8 |
|
Reference adjustment (signed) delta value. |
|
__s8 |
|
Macroblock prediction mode adjustment (signed) delta value. |
|
__u8 |
|
Sharpness level |
|
__u8 |
|
Filter level |
|
__u16 |
|
Applications and drivers must set this to zero. |
|
__u32 |
|
Loop Filter Flags
|
|
0x01 |
Enable/disable macroblock-level loop filter adjustment. |
|
|
0x02 |
Indicates if the delta values used in an adjustment are updated. |
|
|
0x04 |
If set, indicates the filter type is simple. If cleared, the filter type is normal. |
v4l2_vp8_quantization
|
__u8 |
|
Luma AC coefficient table index. |
|
__s8 |
|
Luma DC delta value. |
|
__s8 |
|
Y2 block DC delta value. |
|
__s8 |
|
Y2 block AC delta value. |
|
__s8 |
|
Chroma DC delta value. |
|
__s8 |
|
Chroma AC delta value. |
|
__u16 |
|
Applications and drivers must set this to zero. |
v4l2_vp8_entropy
|
__u8 |
|
Coefficient update probabilities. |
|
__u8 |
|
Luma mode update probabilities. |
|
__u8 |
|
Chroma mode update probabilities. |
|
__u8 |
|
MV decoding update probabilities. |
|
__u8 |
|
Applications and drivers must set this to zero. |
-
V4L2_CID_STATELESS_MPEG2_SEQUENCE (struct)Specifies the sequence parameters (as extracted from the bitstream) for the associated MPEG-2 slice data. This includes fields matching the syntax elements from the sequence header and sequence extension parts of the bitstream as specified by mpeg2part2.
v4l2_ctrl_mpeg2_sequence
|
__u16 |
|
The width of the displayable part of the frame's luminance component. |
|
__u16 |
|
The height of the displayable part of the frame's luminance component. |
|
__u32 |
|
Used to calculate the required size of the video buffering verifier, defined (in bits) as: 16 * 1024 * vbv_buffer_size. |
|
__u16 |
|
The current profile and level indication as extracted from the bitstream. |
|
__u8 |
|
The chrominance sub-sampling format (1: 4:2:0, 2: 4:2:2, 3: 4:4:4). |
|
__u8 |
|
MPEG-2 Sequence Flags
|
|
0x01 |
Indication that all the frames for the sequence are progressive instead of interlaced. |
-
V4L2_CID_STATELESS_MPEG2_PICTURE (struct)Specifies the picture parameters (as extracted from the bitstream) for the associated MPEG-2 slice data. This includes fields matching the syntax elements from the picture header and picture coding extension parts of the bitstream as specified by mpeg2part2.
v4l2_ctrl_mpeg2_picture
|
__u64 |
|
Timestamp of the V4L2 capture buffer to use as backward reference, used with B-coded and P-coded frames. The timestamp refers to the |
|
__u64 |
|
Timestamp for the V4L2 capture buffer to use as forward reference, used with B-coded frames. The timestamp refers to the |
|
__u32 |
|
See MPEG-2 Picture Flags. |
|
__u8 |
|
Motion vector codes. |
|
__u8 |
|
Picture coding type for the frame covered by the current slice (V4L2_MPEG2_PIC_CODING_TYPE_I, V4L2_MPEG2_PIC_CODING_TYPE_P or V4L2_MPEG2_PIC_CODING_TYPE_B). |
|
__u8 |
|
Picture structure (1: interlaced top field, 2: interlaced bottom field, 3: progressive frame). |
|
__u8 |
|
Precision of Discrete Cosine transform (0: 8 bits precision, 1: 9 bits precision, 2: 10 bits precision, 3: 11 bits precision). |
|
__u8 |
|
Applications and drivers must set this to zero. |
MPEG-2 Picture Flags
|
|
0x00000001 |
If set and it's an interlaced stream, top field is output first. |
|
|
0x00000002 |
If set only frame-DCT and frame prediction are used. |
|
|
0x00000004 |
If set motion vectors are coded for intra macroblocks. |
|
|
0x00000008 |
This flag affects the inverse quantization process. |
|
|
0x00000010 |
This flag affects the decoding of transform coefficient data. |
|
|
0x00000020 |
This flag affects the decoding of transform coefficient data. |
|
|
0x00000040 |
This flag affects the decoding process of progressive frames. |
|
|
0x00000080 |
Indicates whether the current frame is progressive. |
-
V4L2_CID_STATELESS_MPEG2_QUANTISATION (struct)Specifies quantisation matrices, in zigzag scanning order, for the associated MPEG-2 slice data. This control is initialized by the kernel to the matrices default values. If a bitstream transmits a user-defined quantisation matrices load, applications are expected to use this control. Applications are also expected to set the control loading the default values, if the quantisation matrices need to be reset, for instance on a sequence header. This process is specified by section 6.3.7. "Quant matrix extension" of the specification.
v4l2_ctrl_mpeg2_quantisation
|
__u8 |
|
The quantisation matrix coefficients for intra-coded frames, in zigzag scanning order. It is relevant for both luma and chroma components, although it can be superseded by the chroma-specific matrix for non-4:2:0 YUV formats. |
|
__u8 |
|
The quantisation matrix coefficients for non-intra-coded frames, in zigzag scanning order. It is relevant for both luma and chroma components, although it can be superseded by the chroma-specific matrix for non-4:2:0 YUV formats. |
|
__u8 |
|
The quantisation matrix coefficients for the chominance component of intra-coded frames, in zigzag scanning order. Only relevant for non-4:2:0 YUV formats. |
|
__u8 |
|
The quantisation matrix coefficients for the chrominance component of non-intra-coded frames, in zigzag scanning order. Only relevant for non-4:2:0 YUV formats. |
-
V4L2_CID_STATELESS_VP9_COMPRESSED_HDR (struct)Stores VP9 probabilities updates as parsed from the current compressed frame header. A value of zero in an array element means no update of the relevant probability. Motion vector-related updates contain a new value or zero. All other updates contain values translated with inv_map_table[] (see 6.3.5 in vp9).
v4l2_ctrl_vp9_compressed_hdr
|
__u8 |
|
Specifies the TX mode. See TX Mode for more details. |
|
__u8 |
|
TX 8x8 probabilities delta. |
|
__u8 |
|
TX 16x16 probabilities delta. |
|
__u8 |
|
TX 32x32 probabilities delta. |
|
__u8 |
|
Coefficient probabilities delta. |
|
__u8 |
|
Skip probabilities delta. |
|
__u8 |
|
Inter prediction mode probabilities delta. |
|
__u8 |
|
Interpolation filter probabilities delta. |
|
__u8 |
|
Is inter-block probabilities delta. |
|
__u8 |
|
Compound prediction mode probabilities delta. |
|
__u8 |
|
Single reference probabilities delta. |
|
__u8 |
|
Compound reference probabilities delta. |
|
__u8 |
|
Y prediction mode probabilities delta. |
|
__u8 |
|
UV prediction mode probabilities delta. |
|
__u8 |
|
Partition probabilities delta. |
|
__u8 |
|
Motion vector joint probabilities delta. |
|
__u8 |
|
Motion vector sign probabilities delta. |
|
__u8 |
|
Motion vector class probabilities delta. |
|
__u8 |
|
Motion vector class0 bit probabilities delta. |
|
__u8 |
|
Motion vector bits probabilities delta. |
|
__u8 |
|
Motion vector class0 fractional bit probabilities delta. |
|
__u8 |
|
Motion vector fractional bit probabilities delta. |
|
__u8 |
|
Motion vector class0 high precision fractional bit probabilities delta. |
|
__u8 |
|
Motion vector high precision fractional bit probabilities delta. |
TX Mode
|
|
0 |
Transform size is 4x4. |
|
|
1 |
Transform size can be up to 8x8. |
|
|
2 |
Transform size can be up to 16x16. |
|
|
3 |
transform size can be up to 32x32. |
|
|
4 |
Bitstream contains the transform size for each block. |
See section '7.3.1 Tx mode semantics' of the vp9 specification for more details.
-
V4L2_CID_STATELESS_VP9_FRAME (struct)Specifies the frame parameters for the associated VP9 frame decode request. This includes the necessary parameters for configuring a stateless hardware decoding pipeline for VP9. The bitstream parameters are defined according to vp9.
v4l2_ctrl_vp9_frame
|
struct |
|
Loop filter parameters. See struct |
|
struct |
|
Quantization parameters. See |
|
struct |
|
Segmentation parameters. See |
|
__u32 |
|
Combination of V4L2_VP9_FRAME_FLAG_* flags. See Frame Flags. |
|
__u16 |
|
Compressed header size in bytes. |
|
__u16 |
|
Uncompressed header size in bytes. |
|
__u16 |
|
Add 1 to get the frame width expressed in pixels. See section 7.2.3 in vp9. |
|
__u16 |
|
Add 1 to get the frame height expressed in pixels. See section 7.2.3 in vp9. |
|
__u16 |
|
Add 1 to get the expected render width expressed in pixels. This is not used during the decoding process but might be used by HW scalers to prepare a frame that's ready for scanout. See section 7.2.4 in vp9. |
|
__u16 |
render_height_minus_1 |
Add 1 to get the expected render height expressed in pixels. This is not used during the decoding process but might be used by HW scalers to prepare a frame that's ready for scanout. See section 7.2.4 in vp9. |
|
__u64 |
|
"last" reference buffer timestamp. The timestamp refers to the |
|
__u64 |
|
"golden" reference buffer timestamp. The timestamp refers to the |
|
__u64 |
|
"alt" reference buffer timestamp. The timestamp refers to the |
|
__u8 |
|
a bitfield specifying whether the sign bias is set for a given reference frame. See Reference Frame Sign Bias for more details. |
|
__u8 |
|
specifies whether the frame context should be reset to default values. See Reset Frame Context for more details. |
|
__u8 |
|
Frame context that should be used/updated. |
|
__u8 |
|
VP9 profile. Can be 0, 1, 2 or 3. |
|
__u8 |
|
Component depth in bits. Can be 8, 10 or 12. Note that not all profiles support 10 and/or 12 bits depths. |
|
__u8 |
|
Specifies the filter selection used for performing inter prediction. See Interpolation Filter for more details. |
|
__u8 |
|
Specifies the base 2 logarithm of the width of each tile (where the width is measured in units of 8x8 blocks). Shall be less than or equal to 6. |
|
__u8 |
|
Specifies the base 2 logarithm of the height of each tile (where the height is measured in units of 8x8 blocks). |
|
__u8 |
|
Specifies the type of inter prediction to be used. See Reference Mode for more details. Note that this is derived as part of the compressed header parsing process and for this reason should have been part of :c:type: |
|
__u8 |
|
Applications and drivers must set this to zero. |
Frame Flags
|
|
0x001 |
The frame is a key frame. |
|
|
0x002 |
The frame should be displayed. |
|
|
0x004 |
The decoding should be error resilient. |
|
|
0x008 |
The frame does not reference other frames. |
|
|
0x010 |
The frame can use high precision motion vectors. |
|
|
0x020 |
Frame context should be updated after decoding. |
|
|
0x040 |
Parallel decoding is used. |
|
|
0x080 |
Vertical subsampling is enabled. |
|
|
0x100 |
Horizontal subsampling is enabled. |
|
|
0x200 |
The full UV range is used. |
Reference Frame Sign Bias
|
|
0x1 |
Sign bias is set for the last reference frame. |
|
|
0x2 |
Sign bias is set for the golden reference frame. |
|
|
0x2 |
Sign bias is set for the alt reference frame. |
Reset Frame Context
|
|
0 |
Do not reset any frame context. |
|
|
1 |
Reset the frame context pointed to by |
|
|
2 |
Reset all frame contexts. |
See section '7.2 Uncompressed header semantics' of the vp9 specification for more details.
Interpolation Filter
|
|
0 |
Eight tap filter. |
|
|
1 |
Eight tap smooth filter. |
|
|
2 |
Eeight tap sharp filter. |
|
|
3 |
Bilinear filter. |
|
|
4 |
Filter selection is signaled at the block level. |
See section '7.2.7 Interpolation filter semantics' of the vp9 specification for more details.
Reference Mode
|
|
0 |
Indicates that all the inter blocks use only a single reference frame to generate motion compensated prediction. |
|
|
1 |
Requires all the inter blocks to use compound mode. Single reference frame prediction is not allowed. |
|
|
2 |
Allows each individual inter block to select between single and compound prediction modes. |
See section '7.3.6 Frame reference mode semantics' of the vp9 specification for more details.
v4l2_vp9_segmentation
Encodes the quantization parameters. See section '7.2.10 Segmentation params syntax' of the vp9 specification for more details.
|
__u8 |
|
Data attached to each feature. Data entry is only valid if the feature is enabled. The array shall be indexed with segment number as the first dimension (0..7) and one of V4L2_VP9_SEG_* as the second dimension. See Segment Feature IDs. |
|
__u8 |
|
Bitmask defining which features are enabled in each segment. The value for each segment is a combination of V4L2_VP9_SEGMENT_FEATURE_ENABLED(id) values where id is one of V4L2_VP9_SEG_*. See Segment Feature IDs. |
|
__u8 |
|
Specifies the probability values to be used when decoding a Segment-ID. See '5.15 Segmentation map' section of vp9 for more details. |
|
__u8 |
|
Specifies the probability values to be used when decoding a Predicted-Segment-ID. See '6.4.14 Get segment id syntax' section of vp9 for more details. |
|
__u8 |
|
Combination of V4L2_VP9_SEGMENTATION_FLAG_* flags. See Segmentation Flags. |
|
__u8 |
|
Applications and drivers must set this to zero. |
Segment feature IDs
|
|
0 |
Quantizer segment feature. |
|
|
1 |
Loop filter segment feature. |
|
|
2 |
Reference frame segment feature. |
|
|
3 |
Skip segment feature. |
|
|
4 |
Number of segment features. |
Segmentation Flags
|
|
0x01 |
Indicates that this frame makes use of the segmentation tool. |
|
|
0x02 |
Indicates that the segmentation map should be updated during the decoding of this frame. |
|
|
0x04 |
Indicates that the updates to the segmentation map are coded relative to the existing segmentation map. |
|
|
0x08 |
Indicates that new parameters are about to be specified for each segment. |
|
|
0x10 |
Indicates that the segmentation parameters represent the actual values to be used. |
v4l2_vp9_quantization
Encodes the quantization parameters. See section '7.2.9 Quantization params syntax' of the VP9 specification for more details.
|
__u8 |
|
Indicates the base frame qindex. |
|
__s8 |
|
Indicates the Y DC quantizer relative to base_q_idx. |
|
__s8 |
|
Indicates the UV DC quantizer relative to base_q_idx. |
|
__s8 |
|
Indicates the UV AC quantizer relative to base_q_idx. |
|
__u8 |
|
Applications and drivers must set this to zero. |
v4l2_vp9_loop_filter
This structure contains all loop filter related parameters. See sections '7.2.8 Loop filter semantics' of the vp9 specification for more details.
|
__s8 |
|
Contains the adjustment needed for the filter level based on the chosen reference frame. |
|
__s8 |
|
Contains the adjustment needed for the filter level based on the chosen mode. |
|
__u8 |
|
Indicates the loop filter strength. |
|
__u8 |
|
Indicates the sharpness level. |
|
__u8 |
|
Combination of V4L2_VP9_LOOP_FILTER_FLAG_* flags. See Loop Filter Flags. |
|
__u8 |
|
Applications and drivers must set this to zero. |
Loop Filter Flags
|
|
0x1 |
When set, the filter level depends on the mode and reference frame used to predict a block. |
|
|
0x2 |
When set, the bitstream contains additional syntax elements that specify which mode and reference frame deltas are to be updated. |
-
V4L2_CID_STATELESS_HEVC_SPS (struct)Specifies the Sequence Parameter Set fields (as extracted from the bitstream) for the associated HEVC slice data. These bitstream parameters are defined according to hevc. They are described in section 7.4.3.2 "Sequence parameter set RBSP semantics" of the specification.
v4l2_ctrl_hevc_sps
|
__u8 |
|
Specifies the value of the vps_video_parameter_set_id of the active VPS as described in section "7.4.3.2.1 General sequence parameter set RBSP semantics" of H.265 specifications. |
|
__u8 |
|
Provides an identifier for the SPS for reference by other syntax elements as described in section "7.4.3.2.1 General sequence parameter set RBSP semantics" of H.265 specifications. |
|
__u16 |
|
Specifies the width of each decoded picture in units of luma samples. |
|
__u16 |
|
Specifies the height of each decoded picture in units of luma samples. |
|
__u8 |
|
This value plus 8 specifies the bit depth of the samples of the luma array. |
|
__u8 |
|
This value plus 8 specifies the bit depth of the samples of the chroma arrays. |
|
__u8 |
|
Specifies the value of the variable MaxPicOrderCntLsb. |
|
__u8 |
|
This value plus 1 specifies the maximum required size of the decoded picture buffer for the coded video sequence (CVS). |
|
__u8 |
|
Indicates the maximum allowed number of pictures. |
|
__u8 |
|
Used to signal MaxLatencyPictures, which indicates the maximum number of pictures that can precede any picture in output order and follow that picture in decoding order. |
|
__u8 |
|
This value plus 3 specifies the minimum luma coding block size. |
|
__u8 |
|
Specifies the difference between the maximum and minimum luma coding block size. |
|
__u8 |
|
This value plus 2 specifies the minimum luma transform block size. |
|
__u8 |
|
Specifies the difference between the maximum and minimum luma transform block size. |
|
__u8 |
|
Specifies the maximum hierarchy depth for transform units of coding units coded in inter prediction mode. |
|
__u8 |
|
Specifies the maximum hierarchy depth for transform units of coding units coded in intra prediction mode. |
|
__u8 |
|
This value plus 1 specifies the number of bits used to represent each of PCM sample values of the luma component. |
|
__u8 |
|
Specifies the number of bits used to represent each of PCM sample values of the chroma components. |
|
__u8 |
|
Plus 3 specifies the minimum size of coding blocks. |
|
__u8 |
|
Specifies the difference between the maximum and minimum size of coding blocks. |
|
__u8 |
|
Specifies the number of st_ref_pic_set() syntax structures included in the SPS. |
|
__u8 |
|
Specifies the number of candidate long-term reference pictures that are specified in the SPS. |
|
__u8 |
|
Specifies the chroma sampling. |
|
__u8 |
|
This value plus 1 specifies the maximum number of temporal sub-layers. |
|
__u64 |
|
Sequence Parameter Set Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
|
|
|
0x00000004 |
|
|
|
0x00000008 |
|
|
|
0x00000010 |
|
|
|
0x00000020 |
|
|
|
0x00000040 |
|
|
|
0x00000080 |
|
|
|
0x00000100 |
-
V4L2_CID_STATELESS_HEVC_PPS (struct)Specifies the Picture Parameter Set fields (as extracted from the bitstream) for the associated HEVC slice data. These bitstream parameters are defined according to hevc. They are described in section 7.4.3.3 "Picture parameter set RBSP semantics" of the specification.
v4l2_ctrl_hevc_pps
|
__u8 |
|
Identifies the PPS for reference by other syntax elements. |
|
__u8 |
|
Specifies the number of extra slice header bits that are present in the slice header RBSP for coded pictures referring to the PPS. |
|
__u8 |
|
This value plus 1 specifies the inferred value of num_ref_idx_l0_active_minus1. |
|
__u8 |
|
This value plus 1 specifies the inferred value of num_ref_idx_l1_active_minus1. |
|
__s8 |
|
This value plus 26 specifies the initial value of SliceQp Y for each slice referring to the PPS. |
|
__u8 |
|
Specifies the difference between the luma coding tree block size and the minimum luma coding block size of coding units that convey cu_qp_delta_abs and cu_qp_delta_sign_flag. |
|
__s8 |
|
Specifies the offsets to the luma quantization parameter Cb. |
|
__s8 |
|
Specifies the offsets to the luma quantization parameter Cr. |
|
__u8 |
|
This value plus 1 specifies the number of tile columns partitioning the picture. |
|
__u8 |
|
This value plus 1 specifies the number of tile rows partitioning the picture. |
|
__u8 |
|
This value plus 1 specifies the width of the i-th tile column in units of coding tree blocks. |
|
__u8 |
|
This value plus 1 specifies the height of the i-th tile row in units of coding tree blocks. |
|
__s8 |
|
Specifies the default deblocking parameter offsets for beta divided by 2. |
|
__s8 |
|
Specifies the default deblocking parameter offsets for tC divided by 2. |
|
__u8 |
|
This value plus 2 specifies the value of the variable Log2ParMrgLevel. |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
__u64 |
|
Picture Parameter Set Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
|
|
|
0x00000004 |
|
|
|
0x00000008 |
|
|
|
0x00000010 |
|
|
|
0x00000020 |
|
|
|
0x00000040 |
|
|
|
0x00000080 |
|
|
|
0x00000100 |
|
|
|
0x00000200 |
|
|
|
0x00000400 |
|
|
|
0x00000800 |
|
|
|
0x00001000 |
|
|
|
0x00002000 |
|
|
|
0x00004000 |
|
|
|
0x00008000 |
|
|
|
0x00010000 |
|
|
|
0x00020000 |
|
|
|
0x00040000 |
|
|
|
0x00080000 |
Specifies the presence of deblocking filter control syntax elements in the PPS |
|
|
0x00100000 |
Specifies that tile column boundaries and likewise tile row boundaries are distributed uniformly across the picture |
-
V4L2_CID_STATELESS_HEVC_SLICE_PARAMS (struct)Specifies various slice-specific parameters, especially from the NAL unit header, general slice segment header and weighted prediction parameter parts of the bitstream. These bitstream parameters are defined according to hevc. They are described in section 7.4.7 "General slice segment header semantics" of the specification. This control is a dynamically sized 1-dimensional array, V4L2_CTRL_FLAG_DYNAMIC_ARRAY flag must be set when using it.
v4l2_ctrl_hevc_slice_params
|
__u32 |
|
Size (in bits) of the current slice data. |
|
__u32 |
|
Offset (in byte) to the video data in the current slice data. |
|
__u32 |
|
Specifies the number of entry point offset syntax elements in the slice header. When the driver supports it, the |
|
__u8 |
|
Specifies the coding type of the slice (B, P or I). |
|
__u8 |
|
Minus 1 specifies a temporal identifier for the NAL unit. |
|
__u8 |
|
(V4L2_HEVC_SLICE_TYPE_I, V4L2_HEVC_SLICE_TYPE_P or V4L2_HEVC_SLICE_TYPE_B). |
|
__u8 |
|
Specifies the colour plane associated with the current slice. |
|
__s32 |
|
Specifies the picture order count. |
|
__u8 |
|
This value plus 1 specifies the maximum reference index for reference picture list 0 that may be used to decode the slice. |
|
__u8 |
|
This value plus 1 specifies the maximum reference index for reference picture list 1 that may be used to decode the slice. |
|
__u8 |
|
Specifies the reference index of the collocated picture used for temporal motion vector prediction. |
|
__u8 |
|
Specifies the maximum number of merging motion vector prediction candidates supported in the slice subtracted from 5. |
|
__s8 |
|
Specifies the initial value of QpY to be used for the coding blocks in the slice. |
|
__s8 |
|
Specifies a difference to be added to the value of pps_cb_qp_offset. |
|
__s8 |
|
Specifies a difference to be added to the value of pps_cr_qp_offset. |
|
__s8 |
|
Specifies the offset to the luma of quantization parameter qP derived in section 8.6.2 |
|
__s8 |
|
Specifies the offset to the cb of quantization parameter qP derived in section 8.6.2 |
|
__s8 |
|
Specifies the offset to the cr of quantization parameter qP derived in section 8.6.2 |
|
__s8 |
|
Specifies the deblocking parameter offsets for beta divided by 2. |
|
__s8 |
|
Specifies the deblocking parameter offsets for tC divided by 2. |
|
__u8 |
|
Indicates whether a picture should be displayed as a frame or as one or more fields. |
|
__u32 |
|
Specifies the address of the first coding tree block in the slice segment. |
|
__u8 |
|
The list of L0 reference elements as indices in the DPB. |
|
__u8 |
|
The list of L1 reference elements as indices in the DPB. |
|
__u16 |
|
Specifies the size, in bits, of the short-term reference picture set, described as st_ref_pic_set() in the specification, included in the slice header or SPS (section 7.3.6.1). |
|
__u16 |
|
Specifies the size, in bits, of the long-term reference picture set include in the slice header or SPS. It is the number of bits in the conditional block if(long_term_ref_pics_present_flag) in section 7.3.6.1 of the specification. |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
struct |
|
The prediction weight coefficients for inter-picture prediction. |
|
__u64 |
|
Slice Parameters Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
|
|
|
0x00000004 |
|
|
|
0x00000008 |
|
|
|
0x00000010 |
|
|
|
0x00000020 |
|
|
|
0x00000040 |
|
|
|
0x00000080 |
|
|
|
0x00000100 |
|
|
|
0x00000200 |
-
V4L2_CID_STATELESS_HEVC_ENTRY_POINT_OFFSETS (integer)Specifies entry point offsets in bytes. This control is a dynamically sized array. The number of entry point offsets is reported by the
elemsfield. This bitstream parameter is defined according to hevc. They are described in section 7.4.7.1 "General slice segment header semantics" of the specification. When multiple slices are submitted in a request, the length of this array must be the sum of num_entry_point_offsets of all the slices in the request. -
V4L2_CID_STATELESS_HEVC_SCALING_MATRIX (struct)Specifies the HEVC scaling matrix parameters used for the scaling process for transform coefficients. These matrix and parameters are defined according to hevc. They are described in section 7.4.5 "Scaling list data semantics" of the specification.
v4l2_ctrl_hevc_scaling_matrix
|
__u8 |
|
Scaling list is used for the scaling process for transform coefficients. The values on each scaling list are expected in raster scan order. |
|
__u8 |
|
Scaling list is used for the scaling process for transform coefficients. The values on each scaling list are expected in raster scan order. |
|
__u8 |
|
Scaling list is used for the scaling process for transform coefficients. The values on each scaling list are expected in raster scan order. |
|
__u8 |
|
Scaling list is used for the scaling process for transform coefficients. The values on each scaling list are expected in raster scan order. |
|
__u8 |
|
Scaling list is used for the scaling process for transform coefficients. The values on each scaling list are expected in raster scan order. |
|
__u8 |
|
Scaling list is used for the scaling process for transform coefficients. The values on each scaling list are expected in raster scan order. |
v4l2_hevc_dpb_entry
|
__u64 |
|
Timestamp of the V4L2 capture buffer to use as reference, used with B-coded and P-coded frames. The timestamp refers to the |
|
__u8 |
|
Long term flag for the reference frame (V4L2_HEVC_DPB_ENTRY_LONG_TERM_REFERENCE). The flag is set as described in the ITU HEVC specification chapter "8.3.2 Decoding process for reference picture set". |
|
__u8 |
|
Whether the reference is a field picture or a frame. See HEVC dpb field pic Flags |
|
__s32 |
|
The picture order count of the current picture. |
|
__u8 |
|
Applications and drivers must set this to zero. |
HEVC dpb field pic Flags
|
|
0 |
(progressive) Frame |
|
|
1 |
Top field |
|
|
2 |
Bottom field |
|
|
3 |
Top field, bottom field, in that order |
|
|
4 |
Bottom field, top field, in that order |
|
|
5 |
Top field, bottom field, top field repeated, in that order |
|
|
6 |
Bottom field, top field, bottom field repeated, in that order |
|
|
7 |
Frame doubling |
|
|
8 |
Frame tripling |
|
|
9 |
Top field paired with previous bottom field in output order |
|
|
10 |
Bottom field paired with previous top field in output order |
|
|
11 |
Top field paired with next bottom field in output order |
|
|
12 |
Bottom field paired with next top field in output order |
v4l2_hevc_pred_weight_table
|
__s8 |
|
The difference of the weighting factor applied to the luma prediction value for list 0. |
|
__s8 |
|
The additive offset applied to the luma prediction value for list 0. |
|
__s8 |
|
The difference of the weighting factor applied to the chroma prediction value for list 0. |
|
__s8 |
|
The difference of the additive offset applied to the chroma prediction values for list 0. |
|
__s8 |
|
The difference of the weighting factor applied to the luma prediction value for list 1. |
|
__s8 |
|
The additive offset applied to the luma prediction value for list 1. |
|
__s8 |
|
The difference of the weighting factor applied to the chroma prediction value for list 1. |
|
__s8 |
|
The difference of the additive offset applied to the chroma prediction values for list 1. |
|
__u8 |
|
The base 2 logarithm of the denominator for all luma weighting factors. |
|
__s8 |
|
The difference of the base 2 logarithm of the denominator for all chroma weighting factors. |
|
__u8 |
|
Applications and drivers must set this to zero. |
-
V4L2_CID_STATELESS_HEVC_DECODE_MODE (enum)Specifies the decoding mode to use. Currently exposes slice-based and frame-based decoding but new modes might be added later on. This control is used as a modifier for V4L2_PIX_FMT_HEVC_SLICE pixel format. Applications that support V4L2_PIX_FMT_HEVC_SLICE are required to set this control in order to specify the decoding mode that is expected for the buffer. Drivers may expose a single or multiple decoding modes, depending on what they can support.
v4l2_stateless_hevc_decode_mode
|
|
0 |
Decoding is done at the slice granularity. The OUTPUT buffer must contain a single slice. |
|
|
1 |
Decoding is done at the frame granularity. The OUTPUT buffer must contain all slices needed to decode the frame. |
-
V4L2_CID_STATELESS_HEVC_START_CODE (enum)Specifies the HEVC slice start code expected for each slice. This control is used as a modifier for V4L2_PIX_FMT_HEVC_SLICE pixel format. Applications that support V4L2_PIX_FMT_HEVC_SLICE are required to set this control in order to specify the start code that is expected for the buffer. Drivers may expose a single or multiple start codes, depending on what they can support.
v4l2_stateless_hevc_start_code
|
|
0 |
Selecting this value specifies that HEVC slices are passed to the driver without any start code. The bitstream data should be according to hevc 7.3.1.1 General NAL unit syntax, hence contains emulation prevention bytes when required. |
|
|
1 |
Selecting this value specifies that HEVC slices are expected to be prefixed by Annex B start codes. According to hevc valid start codes can be 3-bytes 0x000001 or 4-bytes 0x00000001. |
-
V4L2_CID_MPEG_VIDEO_BASELAYER_PRIORITY_ID (integer)Specifies a priority identifier for the NAL unit, which will be applied to the base layer. By default this value is set to 0 for the base layer, and the next layer will have the priority ID assigned as 1, 2, 3 and so on. The video encoder can't decide the priority id to be applied to a layer, so this has to come from client. This is applicable to H264 and valid Range is from 0 to 63. Source Rec. ITU-T H.264 (06/2019); G.7.4.1.1, G.8.8.1.
-
V4L2_CID_MPEG_VIDEO_LTR_COUNT (integer)Specifies the maximum number of Long Term Reference (LTR) frames at any given time that the encoder can keep. This is applicable to the H264 and HEVC encoders.
-
V4L2_CID_MPEG_VIDEO_FRAME_LTR_INDEX (integer)After setting this control the frame that will be queued next will be marked as a Long Term Reference (LTR) frame and given this LTR index which ranges from 0 to LTR_COUNT-1. This is applicable to the H264 and HEVC encoders. Source Rec. ITU-T H.264 (06/2019); Table 7.9
-
V4L2_CID_MPEG_VIDEO_USE_LTR_FRAMES (bitmask)Specifies the Long Term Reference (LTR) frame(s) to be used for encoding the next frame queued after setting this control. This provides a bitmask which consists of bits [0, LTR_COUNT-1]. This is applicable to the H264 and HEVC encoders.
-
V4L2_CID_STATELESS_HEVC_DECODE_PARAMS (struct)Specifies various decode parameters, especially the references picture order count (POC) for all the lists (short, long, before, current, after) and the number of entries for each of them. These parameters are defined according to hevc. They are described in section 8.3 "Slice decoding process" of the specification.
v4l2_ctrl_hevc_decode_params
|
__s32 |
|
PicOrderCntVal as described in section 8.3.1 "Decoding process for picture order count" of the specification. |
|
__u16 |
|
Specifies the size, in bits, of the short-term reference picture set, of the first slice described as st_ref_pic_set() in the specification, included in the slice header or SPS (section 7.3.6.1). |
|
__u16 |
|
Specifies the size, in bits, of the long-term reference picture set, of the first slice included in the slice header or SPS. It is the number of bits in the conditional block if(long_term_ref_pics_present_flag) in section 7.3.6.1 of the specification. |
|
__u8 |
|
The number of entries in |
|
__u8 |
|
The number of reference pictures in the short-term set that come before the current frame. |
|
__u8 |
|
The number of reference pictures in the short-term set that come after the current frame. |
|
__u8 |
|
The number of reference pictures in the long-term set. |
|
__u8 |
|
PocStCurrBefore as described in section 8.3.2 "Decoding process for reference picture set": provides the index of the short term before references in DPB array. |
|
__u8 |
|
PocStCurrAfter as described in section 8.3.2 "Decoding process for reference picture set": provides the index of the short term after references in DPB array. |
|
__u8 |
|
PocLtCurr as described in section 8.3.2 "Decoding process for reference picture set": provides the index of the long term references in DPB array. |
|
__u8 |
|
When the short_term_ref_pic_set_sps_flag in the slice header is equal to 0, it is the same as the derived value NumDeltaPocs[RefRpsIdx]. It can be used to parse the RPS data in slice headers instead of skipping it with @short_term_ref_pic_set_size. When the value of short_term_ref_pic_set_sps_flag in the slice header is equal to 1, num_delta_pocs_of_ref_rps_idx shall be set to 0. |
|
struct |
|
The decoded picture buffer, for meta-data about reference frames. |
|
__u64 |
|
Decode Parameters Flags
|
|
0x00000001 |
|
|
|
0x00000002 |
|
|
|
0x00000004 |
-
V4L2_CID_STATELESS_HEVC_EXT_SPS_LT_RPS (struct)Subset of the
v4l2_ctrl_hevc_spscontrol. It extends it with the list of Long-term reference sets parameters. These parameters are defined according to hevc. They are described in section 7.4.3.2.1 "General sequence parameter set RBSP semantics" of the specification. This control is a dynamically sized 1-dimensional array. The values in the array should be ignored when either num_long_term_ref_pics_sps is 0 or the V4L2_HEVC_SPS_FLAG_LONG_TERM_REF_PICS_PRESENT flag is not set inv4l2_ctrl_hevc_sps.
v4l2_ctrl_hevc_ext_sps_lt_rps
|
__u16 |
|
Long term reference picture order count as described in section 7.4.3.2.1 "General sequence parameter set RBSP semantics" of the specification. |
|
__u16 |
|
Extended SPS Long-Term RPS Flags
|
|
0x00000001 |
Specifies if the long-term reference picture is used 7.4.3.2.1 "General sequence parameter set RBSP semantics" of the specification. |
-
V4L2_CID_STATELESS_HEVC_EXT_SPS_ST_RPS (struct)Subset of the
v4l2_ctrl_hevc_spscontrol. It extends it with the list of Short-term reference sets parameters. These parameters are defined according to hevc. They are described in section 7.4.8 "Short-term reference picture set semantics" of the specification. This control is a dynamically sized 1-dimensional array. The values in the array should be ignored when num_short_term_ref_pic_sets is 0.
v4l2_ctrl_hevc_ext_sps_st_rps
|
__u8 |
|
Specifies the delta compare to the index. See details in section 7.4.8 "Short-term reference picture set semantics" of the specification. |
|
__u8 |
|
Sign of the delta as specified in section 7.4.8 "Short-term reference picture set semantics" of the specification. |
|
__u8 |
|
Number of short-term RPS entries that have picture order count values less than the picture order count value of the current picture. |
|
__u8 |
|
Number of short-term RPS entries that have picture order count values greater than the picture order count value of the current picture. |
|
__u32 |
|
Bit i specifies if short-term RPS i is used by the current picture. |
|
__u32 |
|
Bit i specifies if short-term RPS i is included in the short-term RPS entries. |
|
__u16 |
|
Absolute delta RPS as specified in section 7.4.8 "Short-term reference picture set semantics" of the specification. |
|
__u16 |
|
Specifies the negative picture order count delta for the i-th entry in the short-term RPS. See details in section 7.4.8 "Short-term reference picture set semantics" of the specification. |
|
__u16 |
|
Specifies the positive picture order count delta for the i-th entry in the short-term RPS. See details in section 7.4.8 "Short-term reference picture set semantics" of the specification. |
|
__u16 |
|
Extended SPS Short-Term RPS Flags
|
|
0x00000001 |
Specifies if the short-term RPS is predicted from another short term RPS. See details in section 7.4.8 "Short-term reference picture set semantics" of the specification. |
-
V4L2_CID_STATELESS_AV1_SEQUENCE (struct)Represents an AV1 Sequence OBU (Open Bitstream Unit). See section 5.5 "Sequence header OBU syntax" in av1 for more details.
v4l2_ctrl_av1_sequence
|
__u32 |
|
See AV1 Sequence Flags. |
|
__u8 |
|
Specifies the features that can be used in the coded video sequence. |
|
__u8 |
|
Specifies the number of bits used for the order_hint field at each frame. |
|
__u8 |
|
the bit depth to use for the sequence as described in section 5.5.2 "Color config syntax" in av1 for more details. |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
__u16 |
|
Specifies the maximum frame width minus 1 for the frames represented by this sequence header. |
|
__u16 |
|
Specifies the maximum frame height minus 1 for the frames represented by this sequence header. |
AV1 Sequence Flags
|
|
0x00000001 |
If set, specifies that the coded video sequence contains only one coded frame. If not set, specifies that the coded video sequence contains one or more coded frames. |
|
|
0x00000002 |
If set, indicates that superblocks contain 128x128 luma samples. When equal to 0, it indicates that superblocks contain 64x64 luma samples. The number of contained chroma samples depends on subsampling_x and subsampling_y. |
|
|
0x00000004 |
If set, specifies that the use_filter_intra syntax element may be present. If not set, specifies that the use_filter_intra syntax element will not be present. |
|
|
0x00000008 |
Specifies whether the intra edge filtering process should be enabled. |
|
|
0x00000010 |
If set, specifies that the mode info for inter blocks may contain the syntax element interintra. If not set, specifies that the syntax element interintra will not be present. |
|
|
0x00000020 |
If set, specifies that the mode info for inter blocks may contain the syntax element compound_type. If not set, specifies that the syntax element compound_type will not be present. |
|
|
0x00000040 |
If set, indicates that the allow_warped_motion syntax element may be present. If not set, indicates that the allow_warped_motion syntax element will not be present. |
|
|
0x00000080 |
If set, indicates that the inter prediction filter type may be specified independently in the horizontal and vertical directions. If the flag is equal to 0, only one filter type may be specified, which is then used in both directions. |
|
|
0x00000100 |
If set, indicates that tools based on the values of order hints may be used. If not set, indicates that tools based on order hints are disabled. |
|
|
0x00000200 |
If set, indicates that the distance weights process may be used for inter prediction. |
|
|
0x00000400 |
If set, indicates that the use_ref_frame_mvs syntax element may be present. If not set, indicates that the use_ref_frame_mvs syntax element will not be present. |
|
|
0x00000800 |
If set, specifies that the use_superres syntax element will be present in the uncompressed header. If not set, specifies that the use_superres syntax element will not be present (instead use_superres will be set to 0 in the uncompressed header without being read). |
|
|
0x00001000 |
If set, specifies that cdef filtering may be enabled. If not set, specifies that cdef filtering is disabled. |
|
|
0x00002000 |
If set, specifies that loop restoration filtering may be enabled. If not set, specifies that loop restoration filtering is disabled. |
|
|
0x00004000 |
If set, indicates that the video does not contain U and V color planes. If not set, indicates that the video contains Y, U, and V color planes. |
|
|
0x00008000 |
If set, signals full swing representation, i.e. "Full Range Quantization". If not set, signals studio swing representation, i.e. "Limited Range Quantization". |
|
|
0x00010000 |
Specify the chroma subsampling format. |
|
|
0x00020000 |
Specify the chroma subsampling format. |
|
|
0x00040000 |
Specifies whether film grain parameters are present in the coded video sequence. |
|
|
0x00080000 |
If set, indicates that the U and V planes may have separate delta quantizer values. If not set, indicates that the U and V planes will share the same delta quantizer value. |
-
V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY (struct)Represents a single AV1 tile inside an AV1 Tile Group. Note that MiRowStart, MiRowEnd, MiColStart and MiColEnd can be retrieved from struct v4l2_av1_tile_info in struct v4l2_ctrl_av1_frame using tile_row and tile_col. See section 6.10.1 "General tile group OBU semantics" in av1 for more details.
v4l2_ctrl_av1_tile_group_entry
|
__u32 |
|
Offset from the OBU data, i.e. where the coded tile data actually starts. |
|
__u32 |
|
Specifies the size in bytes of the coded tile. Equivalent to "TileSize" in av1. |
|
__u32 |
|
Specifies the row of the current tile. Equivalent to "TileRow" in av1. |
|
__u32 |
|
Specifies the column of the current tile. Equivalent to "TileColumn" in av1. |
v4l2_av1_warp_model
AV1 Warp Model as described in section 3 "Symbols and abbreviated terms" of av1.
|
|
0 |
Warp model is just an identity transform. |
|
|
1 |
Warp model is a pure translation. |
|
|
2 |
Warp model is a rotation + symmetric zoom + translation. |
|
|
3 |
Warp model is a general affine transform. |
v4l2_av1_reference_frame
AV1 Reference Frames as described in section 6.10.24 "Ref frames semantics" of av1.
|
|
0 |
Intra Frame Reference. |
|
|
1 |
Last Frame Reference. |
|
|
2 |
Last2 Frame Reference. |
|
|
3 |
Last3 Frame Reference. |
|
|
4 |
Golden Frame Reference. |
|
|
5 |
BWD Frame Reference. |
|
|
6 |
ALTREF2 Frame Reference. |
|
|
7 |
ALTREF Frame Reference. |
v4l2_av1_global_motion
AV1 Global Motion parameters as described in section 6.8.17 "Global motion params semantics" of av1.
|
__u8 |
|
A bitfield containing the flags per reference frame. See AV1 Global Motion Flags for more details. |
|
enum |
|
The type of global motion transform used. |
|
__s32 |
|
This field has the same meaning as "gm_params" in av1. |
|
__u8 |
|
Bitfield indicating whether the global motion params are invalid for a given reference frame. See section 7.11.3.6 Setup shear process and the variable "warpValid". Use V4L2_AV1_GLOBAL_MOTION_IS_INVALID(ref) to create a suitable mask. |
|
__u8 |
|
Applications and drivers must set this to zero. |
AV1 Global Motion Flags
|
|
0x00000001 |
Specifies whether global motion parameters are present for a particular reference frame. |
|
|
0x00000002 |
Specifies whether a particular reference frame uses rotation and zoom global motion. |
|
|
0x00000004 |
Specifies whether a particular reference frame uses translation global motion |
v4l2_av1_frame_restoration_type
AV1 Frame Restoration Type.
|
|
0 |
No filtering is applied. |
|
|
1 |
Wiener filter process is invoked. |
|
|
2 |
Self guided filter process is invoked. |
|
|
3 |
Restoration filter is swichtable. |
v4l2_av1_loop_restoration
AV1 Loop Restoration as described in section 6.10.15 "Loop restoration params semantics" of av1.
|
__u8 |
|
|
|
__u8 |
|
Specifies if the luma restoration size should be halved. |
|
__u8 |
|
Specifies if the chroma size should be half the luma size. |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
|
|
Specifies the type of restoration used for each plane. |
|
__u8 |
|
Specifies the size of loop restoration units in units of samples in the current plane. |
AV1 Loop Restoration Flags
|
|
0x00000001 |
Retains the same meaning as UsesLr in av1. |
|
|
0x00000002 |
Retains the same meaning as UsesChromaLr in av1. |
v4l2_av1_cdef
AV1 CDEF params semantics as described in section 6.10.14 "CDEF params semantics" of av1.
|
__u8 |
|
Controls the amount of damping in the deringing filter. |
|
__u8 |
|
Specifies the number of bits needed to specify which CDEF filter to apply. |
|
__u8 |
|
Specifies the strength of the primary filter. |
|
__u8 |
|
Specifies the strength of the secondary filter. |
|
__u8 |
|
Specifies the strength of the primary filter. |
|
__u8 |
|
Specifies the strength of the secondary filter. |
v4l2_av1_segment_feature
AV1 segment features as described in section 3 "Symbols and abbreviated terms" of av1.
|
|
0 |
Index for quantizer segment feature. |
|
|
1 |
Index for vertical luma loop filter segment feature. |
|
|
5 |
Index for reference frame segment feature. |
|
|
6 |
Index for skip segment feature. |
|
|
7 |
Index for global mv feature. |
|
|
8 |
Number of segment features. |
v4l2_av1_segmentation
AV1 Segmentation params as defined in section 6.8.13 "Segmentation params semantics" of av1.
|
__u8 |
|
|
|
__u8 |
|
Indicates the highest numbered segment id that has some enabled feature. This is used when decoding the segment id to only decode choices corresponding to used segments. |
|
__u8 |
|
Bitmask defining which features are enabled in each segment. Use V4L2_AV1_SEGMENT_FEATURE_ENABLED to build a suitable mask. |
|
__u16 |
|
Data attached to each feature. Data entry is only valid if the feature is enabled. |
AV1 Segmentation Flags
|
|
0x00000001 |
If set, indicates that this frame makes use of the segmentation tool. If not set, indicates that the frame does not use segmentation. |
|
|
0x00000002 |
If set, indicates that the segmentation map are updated during the decoding of this frame. If not set, indicates that the segmentation map from the previous frame is used. |
|
|
0x00000004 |
If set, indicates that the updates to the segmentation map are coded relative to the existing segmentation map. If not set, indicates that the new segmentation map is coded without reference to the existing segmentation map. |
|
|
0x00000008 |
If set, indicates that the updates to the segmentation map are coded relative to the existing segmentation map. If not set, indicates that the new segmentation map is coded without reference to the existing segmentation map. |
|
|
0x00000010 |
If set, indicates that the segment id will be read before the skip syntax element. If not set, indicates that the skip syntax element will be read first. |
v4l2_av1_loop_filter
AV1 Loop filter params as defined in section 6.8.10 "Loop filter semantics" of av1.
|
__u8 |
|
See AV1 Loop Filter flags for more details. |
|
__u8 |
|
An array containing loop filter strength values. Different loop filter strength values from the array are used depending on the image plane being filtered, and the edge direction (vertical or horizontal) being filtered. |
|
__u8 |
|
indicates the sharpness level. The loop_filter_level and loop_filter_sharpness together determine when a block edge is filtered, and by how much the filtering can change the sample values. The loop filter process is described in section 7.14 of av1. |
|
__u8 |
|
contains the adjustment needed for the filter level based on the chosen reference frame. If this syntax element is not present, it maintains its previous value. |
|
__u8 |
|
contains the adjustment needed for the filter level based on the chosen mode. If this syntax element is not present, it maintains its previous value. |
|
__u8 |
|
specifies the left shift which should be applied to decoded loop filter delta values. |
AV1 Loop Filter Flags
|
|
0x00000001 |
If set, means that the filter level depends on the mode and reference frame used to predict a block. If not set, means that the filter level does not depend on the mode and reference frame. |
|
|
0x00000002 |
If set, means that additional syntax elements are present that specify which mode and reference frame deltas are to be updated. If not set, means that these syntax elements are not present. |
|
|
0x00000004 |
Specifies whether loop filter delta values are present |
|
|
0x00000008 |
A value equal to 1 specifies that separate loop filter deltas are sent for horizontal luma edges, vertical luma edges, the U edges, and the V edges. A value of delta_lf_multi equal to 0 specifies that the same loop filter delta is used for all edges. |
v4l2_av1_quantization
AV1 Quantization params as defined in section 6.8.11 "Quantization params semantics" of av1.
|
__u8 |
|
See AV1 Loop Filter flags for more details. |
|
__u8 |
|
Indicates the base frame qindex. This is used for Y AC coefficients and as the base value for the other quantizers. |
|
__u8 |
|
Indicates the Y DC quantizer relative to base_q_idx. |
|
__u8 |
|
Indicates the U DC quantizer relative to base_q_idx. |
|
__u8 |
|
Indicates the U AC quantizer relative to base_q_idx. |
|
__u8 |
|
Indicates the V DC quantizer relative to base_q_idx. |
|
__u8 |
|
Indicates the V AC quantizer relative to base_q_idx. |
|
__u8 |
|
Specifies the level in the quantizer matrix that should be used for luma plane decoding. |
|
__u8 |
|
Specifies the level in the quantizer matrix that should be used for chroma U plane decoding. |
|
__u8 |
|
Specifies the level in the quantizer matrix that should be used for chroma V plane decoding. |
|
__u8 |
|
Specifies the left shift which should be applied to decoded quantizer index delta values. |
AV1 Quantization Flags
|
|
0x00000001 |
If set, indicates that the U and V delta quantizer values are coded separately. If not set, indicates that the U and V delta quantizer values share a common value. |
|
|
0x00000002 |
If set, specifies that the quantizer matrix will be used to compute quantizers. |
|
|
0x00000004 |
Specifies whether quantizer index delta values are present. |
v4l2_av1_tile_info
AV1 Tile info as defined in section 6.8.14 "Tile info semantics" of ref:av1.
|
__u8 |
|
See AV1 Tile Info flags for more details. |
|
__u8 |
|
Specifies which tile to use for the CDF update. |
|
__u8 |
|
Specifies the number of tiles across the frame. |
|
__u8 |
|
Specifies the number of tiles down the frame. |
|
__u32 |
|
An array specifying the start column (in units of 4x4 luma samples) for each tile across the image. |
|
__u32 |
|
An array specifying the start row (in units of 4x4 luma samples) for each tile across the image. |
|
__u32 |
|
Specifies the width of a tile minus 1 in units of superblocks. |
|
__u32 |
|
Specifies the height of a tile minus 1 in units of superblocks. |
|
__u8 |
|
Specifies the number of bytes needed to code each tile size. |
|
__u8 |
|
Applications and drivers must set this to zero. |
AV1 Tile Info Flags
|
|
0x00000001 |
If set, means that the tiles are uniformly spaced across the frame. (In other words, all tiles are the same size except for the ones at the right and bottom edge which can be smaller). If not set means that the tile sizes are coded. |
v4l2_av1_frame_type
AV1 Frame Type
|
|
0 |
Key frame. |
|
|
1 |
Inter frame. |
|
|
2 |
Intra-only frame. |
|
|
3 |
Switch frame. |
v4l2_av1_interpolation_filter
AV1 Interpolation Filter
|
|
0 |
Eight tap filter. |
|
|
1 |
Eight tap smooth filter. |
|
|
2 |
Eight tap sharp filter. |
|
|
3 |
Bilinear filter. |
|
|
4 |
Filter selection is signaled at the block level. |
v4l2_av1_tx_mode
AV1 Tx mode as described in section 6.8.21 "TX mode semantics" of av1.
|
|
0 |
The inverse transform will use only 4x4 transforms. |
|
|
1 |
The inverse transform will use the largest transform size that fits inside the block. |
|
|
2 |
The choice of transform size is specified explicitly for each block. |
-
V4L2_CID_STATELESS_AV1_FRAME (struct)Represents a Frame Header OBU. See 6.8 "Frame Header OBU semantics" of av1 for more details.
v4l2_ctrl_av1_frame
|
struct |
|
Tile info |
|
struct |
|
Quantization parameters. |
|
__u8 |
|
The denominator for the upscaling ratio. |
|
struct |
|
Segmentation parameters. |
|
struct |
|
Loop filter params |
|
struct |
|
CDEF params |
|
__u8 |
|
Specifies the frames to use for compound prediction when skip_mode is equal to 1. |
|
__u8 |
|
Specifies which reference frame contains the CDF values and other state that should be loaded at the start of the frame. |
|
struct |
|
Loop restoration parameters. |
|
struct |
|
Global motion parameters. |
|
__u32 |
|
See AV1 Frame flags for more details. |
|
enum |
|
Specifies the AV1 frame type |
|
__u32 |
|
Specifies OrderHintBits least significant bits of the expected output order for this frame. |
|
__u32 |
|
The upscaled width. |
|
enum |
|
Specifies the filter selection used for performing inter prediction. |
|
enum |
|
Specifies how the transform size is determined. |
|
__u32 |
|
Add 1 to get the frame's width. |
|
__u32 |
|
Add 1 to get the frame's height. |
|
__u16 |
|
Add 1 to get the render width of the frame in luma samples. |
|
__u16 |
|
Add 1 to get the render height of the frame in luma samples. |
|
__u32 |
|
Specifies the frame id number for the current frame. Frame id numbers are additional information that do not affect the decoding process, but provide decoders with a way of detecting missing reference frames so that appropriate action can be taken. |
|
__u8 |
|
Specifies the frame removal time in units of DecCT clock ticks counted from the removal time of the last random access point for operating point opNum. |
|
__u8 |
|
Applications and drivers must set this to zero. |
|
__u32 |
|
Specifies the expected output order hint for each reference frame. This field corresponds to the OrderHints variable from the specification (section 5.9.2 "Uncompressed header syntax"). As such, this is only used for non-intra frames and ignored otherwise. order_hints[0] is always ignored. |
|
__u64 |
|
The V4L2 timestamp for each of the reference frames enumerated in enum |
|
__s8 |
|
An index into |
|
__u8 |
|
Contains a bitmask that specifies which reference frame slots will be updated with the current frame after it is decoded. |
AV1 Frame Flags
|
|
0x00000001 |
If set, specifies that this frame should be immediately output once decoded. If not set, specifies that this frame should not be immediately output; it may be output later if a later uncompressed header uses show_existing_frame equal to 1. |
|
|
0x00000002 |
If set, specifies that the frame may be output using the show_existing_frame mechanism. If not set, specifies that this frame will not be output using the show_existing_frame mechanism. |
|
|
0x00000004 |
Specifies whether error resilient mode is enabled. |
|
|
0x00000008 |
Specifies whether the CDF update in the symbol decoding process should be disabled. |
|
|
0x00000010 |
If set, indicates that intra blocks may use palette encoding. If not set, indicates that palette encoding is never used. |
|
|
0x00000020 |
If set, specifies that motion vectors will always be integers. If not set, specifies that motion vectors can contain fractional bits. |
|
|
0x00000040 |
If set, indicates that intra block copy may be used in this frame. If not set, indicates that intra block copy is not allowed in this frame. |
|
|
0x00000080 |
If set, indicates that upscaling is needed. |
|
|
0x00000100 |
If set, specifies that motion vectors are specified to eighth pel precision. If not set, specifies that motion vectors are specified to quarter pel precision; |
|
|
0x00000200 |
If not set, specifies that only the SIMPLE motion mode will be used. |
|
|
0x00000400 |
If set specifies that motion vector information from a previous frame can be used when decoding the current frame. If not set, specifies that this information will not be used. |
|
|
0x00000800 |
If set indicates that the end of frame CDF update is disabled. If not set, indicates that the end of frame CDF update is enabled |
|
|
0x00001000 |
If set, indicates that the syntax element motion_mode may be present, if not set, indicates that the syntax element motion_mode will not be present. |
|
|
0x00002000 |
If set, specifies that the mode info for inter blocks contains the syntax element comp_mode that indicates whether to use single or compound reference prediction. If not set, specifies that all inter blocks will use single prediction. |
|
|
0x00004000 |
If set, specifies that the frame is restricted to a reduced subset of the full set of transform types. |
|
|
0x00008000 |
This flag retains the same meaning as SkipModeAllowed in av1. |
|
|
0x00010000 |
If set, specifies that the syntax element skip_mode will be present, if not set, specifies that skip_mode will not be used for this frame. |
|
|
0x00020000 |
If set, specifies that the frame size will either be specified as the size of one of the reference frames, or computed from the frame_width_minus_1 and frame_height_minus_1 syntax elements. If not set, specifies that the frame size is equal to the size in the sequence header. |
|
|
0x00040000 |
If set, specifies that buffer_removal_time is present. If not set, specifies that buffer_removal_time is not present. |
|
|
0x00080000 |
If set, indicates that only two reference frames are explicitly signaled. If not set, indicates that all reference frames are explicitly signaled. |
-
V4L2_CID_STATELESS_AV1_FILM_GRAIN (struct)Represents the optional film grain parameters. See section 6.8.20 "Film grain params semantics" of av1 for more details.
v4l2_ctrl_av1_film_grain
|
__u8 |
|
See AV1 Film Grain Flags. |
|
__u8 |
|
Represents a multiplier for the cr component used in derivation of the input index to the cr component scaling function. |
|
__u16 |
|
Specifies the starting value for the pseudo-random numbers used during film grain synthesis. |
|
__u8 |
|
Indicates which reference frame contains the film grain parameters to be used for this frame. |
|
__u8 |
|
Specifies the number of points for the piece-wise linear scaling function of the luma component. |
|
__u8 |
|
Represents the x (luma value) coordinate for the i-th point of the piecewise linear scaling function for luma component. The values are signaled on the scale of 0..255. In case of 10 bit video, these values correspond to luma values divided by 4. In case of 12 bit video, these values correspond to luma values divided by 16. |
|
__u8 |
|
Represents the scaling (output) value for the i-th point of the piecewise linear scaling function for luma component. |
|
__u8 |
|
Specifies the number of points for the piece-wise linear scaling function of the cb component. |
|
__u8 |
|
Represents the x coordinate for the i-th point of the piece-wise linear scaling function for cb component. The values are signaled on the scale of 0..255. |
|
__u8 |
|
Represents the scaling (output) value for the i-th point of the piecewise linear scaling function for cb component. |
|
__u8 |
|
Represents the number of points for the piece-wise linear scaling function of the cr component. |
|
__u8 |
|
Represents the x coordinate for the i-th point of the piece-wise linear scaling function for cr component. The values are signaled on the scale of 0..255. |
|
__u8 |
|
Represents the scaling (output) value for the i-th point of the piecewise linear scaling function for cr component. |
|
__u8 |
|
Represents the shift - 8 applied to the values of the chroma component. The grain_scaling_minus_8 can take values of 0..3 and determines the range and quantization step of the standard deviation of film grain. |
|
__u8 |
|
Specifies the number of auto-regressive coefficients for luma and chroma. |
|
__u8 |
|
Specifies auto-regressive coefficients used for the Y plane. |
|
__u8 |
|
Specifies auto-regressive coefficients used for the U plane. |
|
__u8 |
|
Specifies auto-regressive coefficients used for the V plane. |
|
__u8 |
|
Specifies the range of the auto-regressive coefficients. Values of 0, 1, 2, and 3 correspond to the ranges for auto-regressive coefficients of [-2, 2), [-1, 1), [-0.5, 0.5) and [-0.25, 0.25) respectively. |
|
__u8 |
|
Specifies how much the Gaussian random numbers should be scaled down during the grain synthesis process. |
|
__u8 |
|
Represents a multiplier for the cb component used in derivation of the input index to the cb component scaling function. |
|
__u8 |
|
Represents a multiplier for the average luma component used in derivation of the input index to the cb component scaling function.. |
|
__u8 |
|
Represents a multiplier for the average luma component used in derivation of the input index to the cr component scaling function. |
|
__u16 |
|
Represents an offset used in derivation of the input index to the cb component scaling function. |
|
__u16 |
|
Represents an offset used in derivation of the input index to the cr component scaling function. |
|
__u8 |
|
Applications and drivers must set this to zero. |
AV1 Film Grain Flags
|
|
0x00000001 |
If set, specifies that film grain should be added to this frame. If not set, specifies that film grain should not be added. |
|
|
0x00000002 |
If set, means that a new set of parameters should be sent. If not set, specifies that the previous set of parameters should be used. |
|
|
0x00000004 |
If set, specifies that the chroma scaling is inferred from the luma scaling. |
|
|
0x00000008 |
If set, indicates that the overlap between film grain blocks shall be applied. If not set, indicates that the overlap between film grain blocks shall not be applied. |
|
|
0x00000010 |
If set, indicates that clipping to the restricted (studio, i.e. limited) range shall be applied to the sample values after adding the film grain (see the semantics for color_range for an explanation of studio swing). If not set, indicates that clipping to the full range shall be applied to the sample values after adding the film grain. |
Codec Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Below all controls within the Codec control class are described. First the generic controls, then controls specific for certain hardware.
Generic Codec Controls #
Codec Control IDs #
-
V4L2_CID_CODEC_CLASS (class)The Codec class descriptor. Calling ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU for this control will return a description of this control class. This description can be used as the caption of a Tab page in a GUI, for example.
-
V4L2_CID_MPEG_STREAM_TYPE(enum)
-
enum v4l2_mpeg_stream_type -
The MPEG-1, -2 or -4 output stream type. One cannot assume anything here. Each hardware MPEG encoder tends to support different subsets of the available MPEG stream types. This control is specific to multiplexed MPEG streams. The currently defined stream types are:
|
|
MPEG-2 program stream |
|
|
MPEG-2 transport stream |
|
|
MPEG-1 system stream |
|
|
MPEG-2 DVD-compatible stream |
|
|
MPEG-1 VCD-compatible stream |
|
|
MPEG-2 SVCD-compatible stream |
-
V4L2_CID_MPEG_STREAM_PID_PMT (integer)Program Map Table Packet ID for the MPEG transport stream (default 16)
-
V4L2_CID_MPEG_STREAM_PID_AUDIO (integer)Audio Packet ID for the MPEG transport stream (default 256)
-
V4L2_CID_MPEG_STREAM_PID_VIDEO (integer)Video Packet ID for the MPEG transport stream (default 260)
-
V4L2_CID_MPEG_STREAM_PID_PCR (integer)Packet ID for the MPEG transport stream carrying PCR fields (default 259)
-
V4L2_CID_MPEG_STREAM_PES_ID_AUDIO (integer)Audio ID for MPEG PES
-
V4L2_CID_MPEG_STREAM_PES_ID_VIDEO (integer)Video ID for MPEG PES
-
V4L2_CID_MPEG_STREAM_VBI_FMT(enum)
-
enum v4l2_mpeg_stream_vbi_fmt -
Some cards can embed VBI data (e. g. Closed Caption, Teletext) into the MPEG stream. This control selects whether VBI data should be embedded, and if so, what embedding method should be used. The list of possible VBI formats depends on the driver. The currently defined VBI format types are:
|
|
No VBI in the MPEG stream |
|
|
VBI in private packets, IVTV format (documented in the kernel sources in the file |
-
V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ(enum)
-
enum v4l2_mpeg_audio_sampling_freq -
MPEG Audio sampling frequency. Possible values are:
|
|
44.1 kHz |
|
|
48 kHz |
|
|
32 kHz |
-
V4L2_CID_MPEG_AUDIO_ENCODING(enum)
-
enum v4l2_mpeg_audio_encoding -
MPEG Audio encoding. This control is specific to multiplexed MPEG streams. Possible values are:
|
|
MPEG-1/2 Layer I encoding |
|
|
MPEG-1/2 Layer II encoding |
|
|
MPEG-1/2 Layer III encoding |
|
|
MPEG-2/4 AAC (Advanced Audio Coding) |
|
|
AC-3 aka ATSC A/52 encoding |
-
V4L2_CID_MPEG_AUDIO_L1_BITRATE(enum)
-
enum v4l2_mpeg_audio_l1_bitrate -
MPEG-1/2 Layer I bitrate. Possible values are:
|
|
32 kbit/s |
|
|
64 kbit/s |
|
|
96 kbit/s |
|
|
128 kbit/s |
|
|
160 kbit/s |
|
|
192 kbit/s |
|
|
224 kbit/s |
|
|
256 kbit/s |
|
|
288 kbit/s |
|
|
320 kbit/s |
|
|
352 kbit/s |
|
|
384 kbit/s |
|
|
416 kbit/s |
|
|
448 kbit/s |
-
V4L2_CID_MPEG_AUDIO_L2_BITRATE(enum)
-
enum v4l2_mpeg_audio_l2_bitrate -
MPEG-1/2 Layer II bitrate. Possible values are:
|
|
32 kbit/s |
|
|
48 kbit/s |
|
|
56 kbit/s |
|
|
64 kbit/s |
|
|
80 kbit/s |
|
|
96 kbit/s |
|
|
112 kbit/s |
|
|
128 kbit/s |
|
|
160 kbit/s |
|
|
192 kbit/s |
|
|
224 kbit/s |
|
|
256 kbit/s |
|
|
320 kbit/s |
|
|
384 kbit/s |
-
V4L2_CID_MPEG_AUDIO_L3_BITRATE(enum)
-
enum v4l2_mpeg_audio_l3_bitrate -
MPEG-1/2 Layer III bitrate. Possible values are:
|
|
32 kbit/s |
|
|
40 kbit/s |
|
|
48 kbit/s |
|
|
56 kbit/s |
|
|
64 kbit/s |
|
|
80 kbit/s |
|
|
96 kbit/s |
|
|
112 kbit/s |
|
|
128 kbit/s |
|
|
160 kbit/s |
|
|
192 kbit/s |
|
|
224 kbit/s |
|
|
256 kbit/s |
|
|
320 kbit/s |
-
V4L2_CID_MPEG_AUDIO_AAC_BITRATE (integer)AAC bitrate in bits per second.
-
V4L2_CID_MPEG_AUDIO_AC3_BITRATE(enum)
-
enum v4l2_mpeg_audio_ac3_bitrate -
AC-3 bitrate. Possible values are:
|
|
32 kbit/s |
|
|
40 kbit/s |
|
|
48 kbit/s |
|
|
56 kbit/s |
|
|
64 kbit/s |
|
|
80 kbit/s |
|
|
96 kbit/s |
|
|
112 kbit/s |
|
|
128 kbit/s |
|
|
160 kbit/s |
|
|
192 kbit/s |
|
|
224 kbit/s |
|
|
256 kbit/s |
|
|
320 kbit/s |
|
|
384 kbit/s |
|
|
448 kbit/s |
|
|
512 kbit/s |
|
|
576 kbit/s |
|
|
640 kbit/s |
-
V4L2_CID_MPEG_AUDIO_MODE(enum)
-
enum v4l2_mpeg_audio_mode -
MPEG Audio mode. Possible values are:
|
|
Stereo |
|
|
Joint Stereo |
|
|
Bilingual |
|
|
Mono |
-
V4L2_CID_MPEG_AUDIO_MODE_EXTENSION(enum)
-
enum v4l2_mpeg_audio_mode_extension -
Joint Stereo audio mode extension. In Layer I and II they indicate which subbands are in intensity stereo. All other subbands are coded in stereo. Layer III is not (yet) supported. Possible values are:
|
|
Subbands 4-31 in intensity stereo |
|
|
Subbands 8-31 in intensity stereo |
|
|
Subbands 12-31 in intensity stereo |
|
|
Subbands 16-31 in intensity stereo |
-
V4L2_CID_MPEG_AUDIO_EMPHASIS(enum)
-
enum v4l2_mpeg_audio_emphasis -
Audio Emphasis. Possible values are:
|
|
None |
|
|
50/15 microsecond emphasis |
|
|
CCITT J.17 |
-
V4L2_CID_MPEG_AUDIO_CRC(enum)
-
enum v4l2_mpeg_audio_crc -
CRC method. Possible values are:
|
|
None |
|
|
16 bit parity check |
-
V4L2_CID_MPEG_AUDIO_MUTE (boolean)Mutes the audio when capturing. This is not done by muting audio hardware, which can still produce a slight hiss, but in the encoder itself, guaranteeing a fixed and reproducible audio bitstream. 0 = unmuted, 1 = muted.
-
V4L2_CID_MPEG_AUDIO_DEC_PLAYBACK(enum)
-
enum v4l2_mpeg_audio_dec_playback -
Determines how monolingual audio should be played back. Possible values are:
|
|
Automatically determines the best playback mode. |
|
|
Stereo playback. |
|
|
Left channel playback. |
|
|
Right channel playback. |
|
|
Mono playback. |
|
|
Stereo playback with swapped left and right channels. |
-
V4L2_CID_MPEG_AUDIO_DEC_MULTILINGUAL_PLAYBACK(enum)
-
enum v4l2_mpeg_audio_dec_playback -
Determines how multilingual audio should be played back.
-
V4L2_CID_MPEG_VIDEO_ENCODING(enum)
-
enum v4l2_mpeg_video_encoding -
MPEG Video encoding method. This control is specific to multiplexed MPEG streams. Possible values are:
|
|
MPEG-1 Video encoding |
|
|
MPEG-2 Video encoding |
|
|
MPEG-4 AVC (H.264) Video encoding |
-
V4L2_CID_MPEG_VIDEO_ASPECT(enum)
-
enum v4l2_mpeg_video_aspect -
Video aspect. Possible values are:
|
|
|
|
|
|
|
|
-
V4L2_CID_MPEG_VIDEO_B_FRAMES (integer)Number of B-Frames (default 2)
-
V4L2_CID_MPEG_VIDEO_GOP_SIZE (integer)GOP size (default 12)
-
V4L2_CID_MPEG_VIDEO_GOP_CLOSURE (boolean)GOP closure (default 1)
-
V4L2_CID_MPEG_VIDEO_PULLDOWN (boolean)Enable 3:2 pulldown (default 0)
-
V4L2_CID_MPEG_VIDEO_BITRATE_MODE(enum)
-
enum v4l2_mpeg_video_bitrate_mode -
Video bitrate mode. Possible values are:
|
|
Variable bitrate |
|
|
Constant bitrate |
|
|
Constant quality |
-
V4L2_CID_MPEG_VIDEO_BITRATE (integer)Average video bitrate in bits per second.
-
V4L2_CID_MPEG_VIDEO_BITRATE_PEAK (integer)Peak video bitrate in bits per second. Must be larger or equal to the average video bitrate. It is ignored if the video bitrate mode is set to constant bitrate.
-
V4L2_CID_MPEG_VIDEO_CONSTANT_QUALITY (integer)Constant quality level control. This control is applicable when
V4L2_CID_MPEG_VIDEO_BITRATE_MODEvalue isV4L2_MPEG_VIDEO_BITRATE_MODE_CQ. Valid range is 1 to 100 where 1 indicates lowest quality and 100 indicates highest quality. Encoder will decide the appropriate quantization parameter and bitrate to produce requested frame quality.
V4L2_CID_MPEG_VIDEO_FRAME_SKIP_MODE (enum)
-
enum v4l2_mpeg_video_frame_skip_mode -
Indicates in what conditions the encoder should skip frames. If encoding a frame would cause the encoded stream to be larger then a chosen data limit then the frame will be skipped. Possible values are:
|
|
Frame skip mode is disabled. |
|
|
Frame skip mode enabled and buffer limit is set by the chosen level and is defined by the standard. |
|
|
Frame skip mode enabled and buffer limit is set by the VBV (MPEG1/2/4) or CPB (H264) buffer size control. |
-
V4L2_CID_MPEG_VIDEO_TEMPORAL_DECIMATION (integer)For every captured frame, skip this many subsequent frames (default 0).
-
V4L2_CID_MPEG_VIDEO_MUTE (boolean)"Mutes" the video to a fixed color when capturing. This is useful for testing, to produce a fixed video bitstream. 0 = unmuted, 1 = muted.
-
V4L2_CID_MPEG_VIDEO_MUTE_YUV (integer)Sets the "mute" color of the video. The supplied 32-bit integer is interpreted as follows (bit 0 = least significant bit):
|
Bit 0:7 |
V chrominance information |
|
Bit 8:15 |
U chrominance information |
|
Bit 16:23 |
Y luminance information |
|
Bit 24:31 |
Must be zero. |
-
V4L2_CID_MPEG_VIDEO_DEC_PTS (integer64)This read-only control returns the 33-bit video Presentation Time Stamp as defined in ITU T-REC-H.222.0 and ISO/IEC 13818-1 of the currently displayed frame. This is the same PTS as is used in vidioc_decoder_cmd.
-
V4L2_CID_MPEG_VIDEO_DEC_FRAME (integer64)This read-only control returns the frame counter of the frame that is currently displayed (decoded). This value is reset to 0 whenever the decoder is started.
-
V4L2_CID_MPEG_VIDEO_DEC_CONCEAL_COLOR (integer64)This control sets the conceal color in YUV color space. It describes the client preference of the error conceal color in case of an error where the reference frame is missing. The decoder should fill the reference buffer with the preferred color and use it for future decoding. The control is using 16 bits per channel. Applicable to decoders.
|
8bit format |
10bit format |
12bit format |
|
|
Y luminance |
Bit 0:7 |
Bit 0:9 |
Bit 0:11 |
|
Cb chrominance |
Bit 16:23 |
Bit 16:25 |
Bit 16:27 |
|
Cr chrominance |
Bit 32:39 |
Bit 32:41 |
Bit 32:43 |
|
Must be zero |
Bit 48:63 |
Bit 48:63 |
Bit 48:63 |
-
V4L2_CID_MPEG_VIDEO_DECODER_SLICE_INTERFACE (boolean)If enabled the decoder expects to receive a single slice per buffer, otherwise the decoder expects a single frame in per buffer. Applicable to the decoder, all codecs.
-
V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY_ENABLE (boolean)If the display delay is enabled then the decoder is forced to return a CAPTURE buffer (decoded frame) after processing a certain number of OUTPUT buffers. The delay can be set through
V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY. This feature can be used for example for generating thumbnails of videos. Applicable to the decoder. -
V4L2_CID_MPEG_VIDEO_DEC_DISPLAY_DELAY (integer)Display delay value for decoder. The decoder is forced to return a decoded frame after the set 'display delay' number of frames. If this number is low it may result in frames returned out of display order, in addition the hardware may still be using the returned buffer as a reference picture for subsequent frames.
-
V4L2_CID_MPEG_VIDEO_AU_DELIMITER (boolean)If enabled then, AUD (Access Unit Delimiter) NALUs will be generated. That could be useful to find the start of a frame without having to fully parse each NALU. Applicable to the H264 and HEVC encoders.
-
V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_ENABLE (boolean)Enable writing sample aspect ratio in the Video Usability Information. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_VUI_SAR_IDC(enum)
-
enum v4l2_mpeg_video_h264_vui_sar_idc -
VUI sample aspect ratio indicator for H.264 encoding. The value is defined in the table E-1 in the standard. Applicable to the H264 encoder.
|
|
Unspecified |
|
|
1x1 |
|
|
12x11 |
|
|
10x11 |
|
|
16x11 |
|
|
40x33 |
|
|
24x11 |
|
|
20x11 |
|
|
32x11 |
|
|
80x33 |
|
|
18x11 |
|
|
15x11 |
|
|
64x33 |
|
|
160x99 |
|
|
4x3 |
|
|
3x2 |
|
|
2x1 |
|
|
Extended SAR |
-
V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_WIDTH (integer)Extended sample aspect ratio width for H.264 VUI encoding. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_VUI_EXT_SAR_HEIGHT (integer)Extended sample aspect ratio height for H.264 VUI encoding. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_LEVEL(enum)
-
enum v4l2_mpeg_video_h264_level -
The level information for the H264 video elementary stream. Applicable to the H264 encoder. Possible values are:
|
|
Level 1.0 |
|
|
Level 1B |
|
|
Level 1.1 |
|
|
Level 1.2 |
|
|
Level 1.3 |
|
|
Level 2.0 |
|
|
Level 2.1 |
|
|
Level 2.2 |
|
|
Level 3.0 |
|
|
Level 3.1 |
|
|
Level 3.2 |
|
|
Level 4.0 |
|
|
Level 4.1 |
|
|
Level 4.2 |
|
|
Level 5.0 |
|
|
Level 5.1 |
|
|
Level 5.2 |
|
|
Level 6.0 |
|
|
Level 6.1 |
|
|
Level 6.2 |
-
V4L2_CID_MPEG_VIDEO_MPEG2_LEVEL(enum)
-
enum v4l2_mpeg_video_mpeg2_level -
The level information for the MPEG2 elementary stream. Applicable to MPEG2 codecs. Possible values are:
|
|
Low Level (LL) |
|
|
Main Level (ML) |
|
|
High-1440 Level (H-14) |
|
|
High Level (HL) |
-
V4L2_CID_MPEG_VIDEO_MPEG4_LEVEL(enum)
-
enum v4l2_mpeg_video_mpeg4_level -
The level information for the MPEG4 elementary stream. Applicable to the MPEG4 encoder. Possible values are:
|
|
Level 0 |
|
|
Level 0b |
|
|
Level 1 |
|
|
Level 2 |
|
|
Level 3 |
|
|
Level 3b |
|
|
Level 4 |
|
|
Level 5 |
-
V4L2_CID_MPEG_VIDEO_H264_PROFILE(enum)
-
enum v4l2_mpeg_video_h264_profile -
The profile information for H264. Applicable to the H264 encoder. Possible values are:
|
|
Baseline profile |
|
|
Constrained Baseline profile |
|
|
Main profile |
|
|
Extended profile |
|
|
High profile |
|
|
High 10 profile |
|
|
High 422 profile |
|
|
High 444 Predictive profile |
|
|
High 10 Intra profile |
|
|
High 422 Intra profile |
|
|
High 444 Intra profile |
|
|
CAVLC 444 Intra profile |
|
|
Scalable Baseline profile |
|
|
Scalable High profile |
|
|
Scalable High Intra profile |
|
|
Stereo High profile |
|
|
Multiview High profile |
|
|
Constrained High profile |
-
V4L2_CID_MPEG_VIDEO_MPEG2_PROFILE(enum)
-
enum v4l2_mpeg_video_mpeg2_profile -
The profile information for MPEG2. Applicable to MPEG2 codecs. Possible values are:
|
|
Simple profile (SP) |
|
|
Main profile (MP) |
|
|
SNR Scalable profile (SNR) |
|
|
Spatially Scalable profile (Spt) |
|
|
High profile (HP) |
|
|
Multi-view profile (MVP) |
-
V4L2_CID_MPEG_VIDEO_MPEG4_PROFILE(enum)
-
enum v4l2_mpeg_video_mpeg4_profile -
The profile information for MPEG4. Applicable to the MPEG4 encoder. Possible values are:
|
|
Simple profile |
|
|
Advanced Simple profile |
|
|
Core profile |
|
|
Simple Scalable profile |
|
|
Advanced Coding Efficiency profile |
-
V4L2_CID_MPEG_VIDEO_MAX_REF_PIC (integer)The maximum number of reference pictures used for encoding. Applicable to the encoder.
-
V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODE(enum)
-
enum v4l2_mpeg_video_multi_slice_mode -
Determines how the encoder should handle division of frame into slices. Applicable to the encoder. Possible values are:
|
|
Single slice per frame. |
|
|
Multiple slices with set maximum number of macroblocks per slice. |
|
|
Multiple slice with set maximum size in bytes per slice. |
-
V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_MB (integer)The maximum number of macroblocks in a slice. Used when
V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODEis set toV4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_MB. Applicable to the encoder. -
V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MAX_BYTES (integer)The maximum size of a slice in bytes. Used when
V4L2_CID_MPEG_VIDEO_MULTI_SLICE_MODEis set toV4L2_MPEG_VIDEO_MULTI_SLICE_MODE_MAX_BYTES. Applicable to the encoder.
-
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_MODE(enum)
-
enum v4l2_mpeg_video_h264_loop_filter_mode -
Loop filter mode for H264 encoder. Possible values are:
|
|
Loop filter is enabled. |
|
|
Loop filter is disabled. |
|
|
Loop filter is disabled at the slice boundary. |
-
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_ALPHA (integer)Loop filter alpha coefficient, defined in the H264 standard. This value corresponds to the slice_alpha_c0_offset_div2 slice header field, and should be in the range of -6 to +6, inclusive. The actual alpha offset FilterOffsetA is twice this value. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_LOOP_FILTER_BETA (integer)Loop filter beta coefficient, defined in the H264 standard. This corresponds to the slice_beta_offset_div2 slice header field, and should be in the range of -6 to +6, inclusive. The actual beta offset FilterOffsetB is twice this value. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_ENTROPY_MODE(enum)
-
enum v4l2_mpeg_video_h264_entropy_mode -
Entropy coding mode for H264 - CABAC/CAVALC. Applicable to the H264 encoder. Possible values are:
|
|
Use CAVLC entropy coding. |
|
|
Use CABAC entropy coding. |
-
V4L2_CID_MPEG_VIDEO_H264_8X8_TRANSFORM (boolean)Enable 8X8 transform for H264. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_CONSTRAINED_INTRA_PREDICTION (boolean)Enable constrained intra prediction for H264. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_CHROMA_QP_INDEX_OFFSET (integer)Specify the offset that should be added to the luma quantization parameter to determine the chroma quantization parameter. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MB (integer)Cyclic intra macroblock refresh. This is the number of continuous macroblocks refreshed every frame. Each frame a successive set of macroblocks is refreshed until the cycle completes and starts from the top of the frame. Setting this control to zero means that macroblocks will not be refreshed. Note that this control will not take effect when
V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIODcontrol is set to non zero value. Applicable to H264, H263 and MPEG4 encoder.
V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD_TYPE (enum)
-
enum v4l2_mpeg_video_intra_refresh_period_type -
Sets the type of intra refresh. The period to refresh the whole frame is specified by V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD. Note that if this control is not present, then it is undefined what refresh type is used and it is up to the driver to decide. Applicable to H264 and HEVC encoders. Possible values are:
|
|
The whole frame is completely refreshed randomly after the specified period. |
|
|
The whole frame MBs are completely refreshed in cyclic order after the specified period. |
-
V4L2_CID_MPEG_VIDEO_INTRA_REFRESH_PERIOD (integer)Intra macroblock refresh period. This sets the period to refresh the whole frame. In other words, this defines the number of frames for which the whole frame will be intra-refreshed. An example: setting period to 1 means that the whole frame will be refreshed, setting period to 2 means that the half of macroblocks will be intra-refreshed on frameX and the other half of macroblocks will be refreshed in frameX + 1 and so on. Setting the period to zero means no period is specified. Note that if the client sets this control to non zero value the
V4L2_CID_MPEG_VIDEO_CYCLIC_INTRA_REFRESH_MBcontrol shall be ignored. Applicable to H264 and HEVC encoders. -
V4L2_CID_MPEG_VIDEO_FRAME_RC_ENABLE (boolean)Frame level rate control enable. If this control is disabled then the quantization parameter for each frame type is constant and set with appropriate controls (e.g.
V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP). If frame rate control is enabled then quantization parameter is adjusted to meet the chosen bitrate. Minimum and maximum value for the quantization parameter can be set with appropriate controls (e.g.V4L2_CID_MPEG_VIDEO_H263_MIN_QP). Applicable to encoders. -
V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE (boolean)Macroblock level rate control enable. Applicable to the MPEG4 and H264 encoders.
-
V4L2_CID_MPEG_VIDEO_MPEG4_QPEL (boolean)Quarter pixel motion estimation for MPEG4. Applicable to the MPEG4 encoder.
-
V4L2_CID_MPEG_VIDEO_H263_I_FRAME_QP (integer)Quantization parameter for an I frame for H263. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_H263_MIN_QP (integer)Minimum quantization parameter for H263. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_H263_MAX_QP (integer)Maximum quantization parameter for H263. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_H263_P_FRAME_QP (integer)Quantization parameter for an P frame for H263. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_H263_B_FRAME_QP (integer)Quantization parameter for an B frame for H263. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP (integer)Quantization parameter for an I frame for H264. Valid range: from 0 to 51.
-
V4L2_CID_MPEG_VIDEO_H264_MIN_QP (integer)Minimum quantization parameter for H264. Valid range: from 0 to 51.
-
V4L2_CID_MPEG_VIDEO_H264_MAX_QP (integer)Maximum quantization parameter for H264. Valid range: from 0 to 51.
-
V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP (integer)Quantization parameter for an P frame for H264. Valid range: from 0 to 51.
-
V4L2_CID_MPEG_VIDEO_H264_B_FRAME_QP (integer)Quantization parameter for an B frame for H264. Valid range: from 0 to 51.
-
V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MIN_QP (integer)Minimum quantization parameter for the H264 I frame to limit I frame quality to a range. Valid range: from 0 to 51. If V4L2_CID_MPEG_VIDEO_H264_MIN_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_H264_I_FRAME_MAX_QP (integer)Maximum quantization parameter for the H264 I frame to limit I frame quality to a range. Valid range: from 0 to 51. If V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MIN_QP (integer)Minimum quantization parameter for the H264 P frame to limit P frame quality to a range. Valid range: from 0 to 51. If V4L2_CID_MPEG_VIDEO_H264_MIN_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_H264_P_FRAME_MAX_QP (integer)Maximum quantization parameter for the H264 P frame to limit P frame quality to a range. Valid range: from 0 to 51. If V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MIN_QP (integer)Minimum quantization parameter for the H264 B frame to limit B frame quality to a range. Valid range: from 0 to 51. If V4L2_CID_MPEG_VIDEO_H264_MIN_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_H264_B_FRAME_MAX_QP (integer)Maximum quantization parameter for the H264 B frame to limit B frame quality to a range. Valid range: from 0 to 51. If V4L2_CID_MPEG_VIDEO_H264_MAX_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_MPEG4_I_FRAME_QP (integer)Quantization parameter for an I frame for MPEG4. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_MPEG4_MIN_QP (integer)Minimum quantization parameter for MPEG4. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_MPEG4_MAX_QP (integer)Maximum quantization parameter for MPEG4. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_MPEG4_P_FRAME_QP (integer)Quantization parameter for an P frame for MPEG4. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_MPEG4_B_FRAME_QP (integer)Quantization parameter for an B frame for MPEG4. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_VBV_SIZE (integer)The Video Buffer Verifier size in kilobytes, it is used as a limitation of frame skip. The VBV is defined in the standard as a mean to verify that the produced stream will be successfully decoded. The standard describes it as "Part of a hypothetical decoder that is conceptually connected to the output of the encoder. Its purpose is to provide a constraint on the variability of the data rate that an encoder or editing process may produce.". Applicable to the MPEG1, MPEG2, MPEG4 encoders.
-
V4L2_CID_MPEG_VIDEO_VBV_DELAY (integer)Sets the initial delay in milliseconds for VBV buffer control.
-
V4L2_CID_MPEG_VIDEO_MV_H_SEARCH_RANGE (integer)Horizontal search range defines maximum horizontal search area in pixels to search and match for the present Macroblock (MB) in the reference picture. This V4L2 control macro is used to set horizontal search range for motion estimation module in video encoder.
-
V4L2_CID_MPEG_VIDEO_MV_V_SEARCH_RANGE (integer)Vertical search range defines maximum vertical search area in pixels to search and match for the present Macroblock (MB) in the reference picture. This V4L2 control macro is used to set vertical search range for motion estimation module in video encoder.
-
V4L2_CID_MPEG_VIDEO_FORCE_KEY_FRAME (button)Force a key frame for the next queued buffer. Applicable to encoders. This is a general, codec-agnostic keyframe control.
-
V4L2_CID_MPEG_VIDEO_H264_CPB_SIZE (integer)The Coded Picture Buffer size in kilobytes, it is used as a limitation of frame skip. The CPB is defined in the H264 standard as a mean to verify that the produced stream will be successfully decoded. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_I_PERIOD (integer)Period between I-frames in the open GOP for H264. In case of an open GOP this is the period between two I-frames. The period between IDR (Instantaneous Decoding Refresh) frames is taken from the GOP_SIZE control. An IDR frame, which stands for Instantaneous Decoding Refresh is an I-frame after which no prior frames are referenced. This means that a stream can be restarted from an IDR frame without the need to store or decode any previous frames. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_HEADER_MODE(enum)
-
enum v4l2_mpeg_video_header_mode -
Determines whether the header is returned as the first buffer or is it returned together with the first frame. Applicable to encoders. Possible values are:
|
|
The stream header is returned separately in the first buffer. |
|
|
The stream header is returned together with the first encoded frame. |
-
V4L2_CID_MPEG_VIDEO_REPEAT_SEQ_HEADER (boolean)Repeat the video sequence headers. Repeating these headers makes random access to the video stream easier. Applicable to the MPEG1, 2 and 4 encoder.
-
V4L2_CID_MPEG_VIDEO_DECODER_MPEG4_DEBLOCK_FILTER (boolean)Enabled the deblocking post processing filter for MPEG4 decoder. Applicable to the MPEG4 decoder.
-
V4L2_CID_MPEG_VIDEO_MPEG4_VOP_TIME_RES (integer)vop_time_increment_resolution value for MPEG4. Applicable to the MPEG4 encoder.
-
V4L2_CID_MPEG_VIDEO_MPEG4_VOP_TIME_INC (integer)vop_time_increment value for MPEG4. Applicable to the MPEG4 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_SEI_FRAME_PACKING (boolean)Enable generation of frame packing supplemental enhancement information in the encoded bitstream. The frame packing SEI message contains the arrangement of L and R planes for 3D viewing. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_SEI_FP_CURRENT_FRAME_0 (boolean)Sets current frame as frame0 in frame packing SEI. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_SEI_FP_ARRANGEMENT_TYPE(enum)
-
enum v4l2_mpeg_video_h264_sei_fp_arrangement_type -
Frame packing arrangement type for H264 SEI. Applicable to the H264 encoder. Possible values are:
|
|
Pixels are alternatively from L and R. |
|
|
L and R are interlaced by column. |
|
|
L and R are interlaced by row. |
|
|
L is on the left, R on the right. |
|
|
L is on top, R on bottom. |
|
|
One view per frame. |
-
V4L2_CID_MPEG_VIDEO_H264_FMO (boolean)Enables flexible macroblock ordering in the encoded bitstream. It is a technique used for restructuring the ordering of macroblocks in pictures. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_FMO_MAP_TYPE(enum)
-
enum v4l2_mpeg_video_h264_fmo_map_type -
When using FMO, the map type divides the image in different scan patterns of macroblocks. Applicable to the H264 encoder. Possible values are:
|
|
Slices are interleaved one after other with macroblocks in run length order. |
|
|
Scatters the macroblocks based on a mathematical function known to both encoder and decoder. |
|
|
Macroblocks arranged in rectangular areas or regions of interest. |
|
|
Slice groups grow in a cyclic way from centre to outwards. |
|
|
Slice groups grow in raster scan pattern from left to right. |
|
|
Slice groups grow in wipe scan pattern from top to bottom. |
|
|
User defined map type. |
-
V4L2_CID_MPEG_VIDEO_H264_FMO_SLICE_GROUP (integer)Number of slice groups in FMO. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_DIRECTION(enum)
-
enum v4l2_mpeg_video_h264_fmo_change_dir -
Specifies a direction of the slice group change for raster and wipe maps. Applicable to the H264 encoder. Possible values are:
|
|
Raster scan or wipe right. |
|
|
Reverse raster scan or wipe left. |
-
V4L2_CID_MPEG_VIDEO_H264_FMO_CHANGE_RATE (integer)Specifies the size of the first slice group for raster and wipe map. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_FMO_RUN_LENGTH (integer)Specifies the number of consecutive macroblocks for the interleaved map. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_ASO (boolean)Enables arbitrary slice ordering in encoded bitstream. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_ASO_SLICE_ORDER (integer)Specifies the slice order in ASO. Applicable to the H264 encoder. The supplied 32-bit integer is interpreted as follows (bit 0 = least significant bit):
|
Bit 0:15 |
Slice ID |
|
Bit 16:32 |
Slice position or order |
-
V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING (boolean)Enables H264 hierarchical coding. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_TYPE(enum)
-
enum v4l2_mpeg_video_h264_hierarchical_coding_type -
Specifies the hierarchical coding type. Applicable to the H264 encoder. Possible values are:
|
|
Hierarchical B coding. |
|
|
Hierarchical P coding. |
-
V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER (integer)Specifies the number of hierarchical coding layers. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIERARCHICAL_CODING_LAYER_QP (integer)Specifies a user defined QP for each layer. Applicable to the H264 encoder. The supplied 32-bit integer is interpreted as follows (bit 0 = least significant bit):
|
Bit 0:15 |
QP value |
|
Bit 16:32 |
Layer number |
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L0_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 0 for H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L1_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 1 for H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L2_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 2 for H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L3_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 3 for H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L4_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 4 for H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L5_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 5 for H264 encoder.
-
V4L2_CID_MPEG_VIDEO_H264_HIER_CODING_L6_BR (integer)Indicates bit rate (bps) for hierarchical coding layer 6 for H264 encoder.
-
V4L2_CID_FWHT_I_FRAME_QP (integer)Quantization parameter for an I frame for FWHT. Valid range: from 1 to 31.
-
V4L2_CID_FWHT_P_FRAME_QP (integer)Quantization parameter for a P frame for FWHT. Valid range: from 1 to 31.
-
V4L2_CID_MPEG_VIDEO_AVERAGE_QP (integer)This read-only control returns the average QP value of the currently encoded frame. The value applies to the last dequeued capture buffer (VIDIOC_DQBUF). Its valid range depends on the encoding format and parameters. For H264, its valid range is from 0 to 51. For HEVC, its valid range is from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. For H263 and MPEG4, its valid range is from 1 to 31. For VP8, its valid range is from 0 to 127. For VP9, its valid range is from 0 to 255. If the codec's MIN_QP and MAX_QP are set, then the QP will meet both requirements. Codecs need to always use the specified range, rather then a HW custom range. Applicable to encoders
MFC 5.1 MPEG Controls #
The following MPEG class controls deal with MPEG decoding and encoding settings that are specific to the Multi Format Codec 5.1 device present in the S5P family of SoCs by Samsung.
MFC 5.1 Control IDs #
-
V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY_ENABLE (boolean)If the display delay is enabled then the decoder is forced to return a CAPTURE buffer (decoded frame) after processing a certain number of OUTPUT buffers. The delay can be set through
V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY. This feature can be used for example for generating thumbnails of videos. Applicable to the H264 decoder. -
V4L2_CID_MPEG_MFC51_VIDEO_DECODER_H264_DISPLAY_DELAY (integer)Display delay value for H264 decoder. The decoder is forced to return a decoded frame after the set 'display delay' number of frames. If this number is low it may result in frames returned out of display order, in addition the hardware may still be using the returned buffer as a reference picture for subsequent frames.
-
V4L2_CID_MPEG_MFC51_VIDEO_H264_NUM_REF_PIC_FOR_P (integer)The number of reference pictures used for encoding a P picture. Applicable to the H264 encoder.
-
V4L2_CID_MPEG_MFC51_VIDEO_PADDING (boolean)Padding enable in the encoder - use a color instead of repeating border pixels. Applicable to encoders.
-
V4L2_CID_MPEG_MFC51_VIDEO_PADDING_YUV (integer)Padding color in the encoder. Applicable to encoders. The supplied 32-bit integer is interpreted as follows (bit 0 = least significant bit):
|
Bit 0:7 |
V chrominance information |
|
Bit 8:15 |
U chrominance information |
|
Bit 16:23 |
Y luminance information |
|
Bit 24:31 |
Must be zero. |
-
V4L2_CID_MPEG_MFC51_VIDEO_RC_REACTION_COEFF (integer)Reaction coefficient for MFC rate control. Applicable to encoders.
-
V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_DARK (boolean)Adaptive rate control for dark region. Valid only when H.264 and macroblock level RC is enabled (
V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE). Applicable to the H264 encoder. -
V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_SMOOTH (boolean)Adaptive rate control for smooth region. Valid only when H.264 and macroblock level RC is enabled (
V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE). Applicable to the H264 encoder. -
V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_STATIC (boolean)Adaptive rate control for static region. Valid only when H.264 and macroblock level RC is enabled (
V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE). Applicable to the H264 encoder. -
V4L2_CID_MPEG_MFC51_VIDEO_H264_ADAPTIVE_RC_ACTIVITY (boolean)Adaptive rate control for activity region. Valid only when H.264 and macroblock level RC is enabled (
V4L2_CID_MPEG_VIDEO_MB_RC_ENABLE). Applicable to the H264 encoder.
-
V4L2_CID_MPEG_MFC51_VIDEO_FRAME_SKIP_MODE(enum)
-
enum v4l2_mpeg_mfc51_video_frame_skip_mode -
Indicates in what conditions the encoder should skip frames. If encoding a frame would cause the encoded stream to be larger then a chosen data limit then the frame will be skipped. Possible values are:
|
|
Frame skip mode is disabled. |
|
|
Frame skip mode enabled and buffer limit is set by the chosen level and is defined by the standard. |
|
|
Frame skip mode enabled and buffer limit is set by the VBV (MPEG1/2/4) or CPB (H264) buffer size control. |
-
V4L2_CID_MPEG_MFC51_VIDEO_RC_FIXED_TARGET_BIT (integer)Enable rate-control with fixed target bit. If this setting is enabled, then the rate control logic of the encoder will calculate the average bitrate for a GOP and keep it below or equal the set bitrate target. Otherwise the rate control logic calculates the overall average bitrate for the stream and keeps it below or equal to the set bitrate. In the first case the average bitrate for the whole stream will be smaller then the set bitrate. This is caused because the average is calculated for smaller number of frames, on the other hand enabling this setting will ensure that the stream will meet tight bandwidth constraints. Applicable to encoders.
-
V4L2_CID_MPEG_MFC51_VIDEO_FORCE_FRAME_TYPE(enum)
-
enum v4l2_mpeg_mfc51_video_force_frame_type -
Force a frame type for the next queued buffer. Applicable to encoders. Possible values are:
|
|
Forcing a specific frame type disabled. |
|
|
Force an I-frame. |
|
|
Force a non-coded frame. |
CX2341x MPEG Controls #
The following MPEG class controls deal with MPEG encoding settings that are specific to the Conexant CX23415 and CX23416 MPEG encoding chips.
CX2341x Control IDs #
-
V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER_MODE(enum)
-
enum v4l2_mpeg_cx2341x_video_spatial_filter_mode -
Sets the Spatial Filter mode (default
MANUAL). Possible values are:
|
|
Choose the filter manually |
|
|
Choose the filter automatically |
-
V4L2_CID_MPEG_CX2341X_VIDEO_SPATIAL_FILTER (integer (0-15))The setting for the Spatial Filter. 0 = off, 15 = maximum. (Default is 0.)
-
V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_SPATIAL_FILTER_TYPE(enum)
-
enum v4l2_mpeg_cx2341x_video_luma_spatial_filter_type -
Select the algorithm to use for the Luma Spatial Filter (default
1D_HOR). Possible values:
|
|
No filter |
|
|
One-dimensional horizontal |
|
|
One-dimensional vertical |
|
|
Two-dimensional separable |
|
|
Two-dimensional symmetrical non-separable |
-
V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_SPATIAL_FILTER_TYPE(enum)
-
enum v4l2_mpeg_cx2341x_video_chroma_spatial_filter_type -
Select the algorithm for the Chroma Spatial Filter (default
1D_HOR). Possible values are:
|
|
No filter |
|
|
One-dimensional horizontal |
-
V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER_MODE(enum)
-
enum v4l2_mpeg_cx2341x_video_temporal_filter_mode -
Sets the Temporal Filter mode (default
MANUAL). Possible values are:
|
|
Choose the filter manually |
|
|
Choose the filter automatically |
-
V4L2_CID_MPEG_CX2341X_VIDEO_TEMPORAL_FILTER (integer (0-31))The setting for the Temporal Filter. 0 = off, 31 = maximum. (Default is 8 for full-scale capturing and 0 for scaled capturing.)
-
V4L2_CID_MPEG_CX2341X_VIDEO_MEDIAN_FILTER_TYPE(enum)
-
enum v4l2_mpeg_cx2341x_video_median_filter_type -
Median Filter Type (default
OFF). Possible values are:
|
|
No filter |
|
|
Horizontal filter |
|
|
Vertical filter |
|
|
Horizontal and vertical filter |
|
|
Diagonal filter |
-
V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_BOTTOM (integer (0-255))Threshold above which the luminance median filter is enabled (default 0)
-
V4L2_CID_MPEG_CX2341X_VIDEO_LUMA_MEDIAN_FILTER_TOP (integer (0-255))Threshold below which the luminance median filter is enabled (default 255)
-
V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_BOTTOM (integer (0-255))Threshold above which the chroma median filter is enabled (default 0)
-
V4L2_CID_MPEG_CX2341X_VIDEO_CHROMA_MEDIAN_FILTER_TOP (integer (0-255))Threshold below which the chroma median filter is enabled (default 255)
-
V4L2_CID_MPEG_CX2341X_STREAM_INSERT_NAV_PACKETS (boolean)The CX2341X MPEG encoder can insert one empty MPEG-2 PES packet into the stream between every four video frames. The packet size is 2048 bytes, including the packet_start_code_prefix and stream_id fields. The stream_id is 0xBF (private stream 2). The payload consists of 0x00 bytes, to be filled in by the application. 0 = do not insert, 1 = insert packets.
VPX Control Reference #
The VPX controls include controls for encoding parameters of VPx video codec.
VPX Control IDs #
-
V4L2_CID_MPEG_VIDEO_VPX_NUM_PARTITIONS(enum)
-
enum v4l2_vp8_num_partitions -
The number of token partitions to use in VP8 encoder. Possible values are:
|
|
1 coefficient partition |
|
|
2 coefficient partitions |
|
|
4 coefficient partitions |
|
|
8 coefficient partitions |
-
V4L2_CID_MPEG_VIDEO_VPX_IMD_DISABLE_4X4 (boolean)Setting this prevents intra 4x4 mode in the intra mode decision.
-
V4L2_CID_MPEG_VIDEO_VPX_NUM_REF_FRAMES(enum)
-
enum v4l2_vp8_num_ref_frames -
The number of reference pictures for encoding P frames. Possible values are:
|
|
Last encoded frame will be searched |
|
|
Two frames will be searched among the last encoded frame, the golden frame and the alternate reference (altref) frame. The encoder implementation will decide which two are chosen. |
|
|
The last encoded frame, the golden frame and the altref frame will be searched. |
-
V4L2_CID_MPEG_VIDEO_VPX_FILTER_LEVEL (integer)Indicates the loop filter level. The adjustment of the loop filter level is done via a delta value against a baseline loop filter value.
-
V4L2_CID_MPEG_VIDEO_VPX_FILTER_SHARPNESS (integer)This parameter affects the loop filter. Anything above zero weakens the deblocking effect on the loop filter.
-
V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_REF_PERIOD (integer)Sets the refresh period for the golden frame. The period is defined in number of frames. For a value of 'n', every nth frame starting from the first key frame will be taken as a golden frame. For eg. for encoding sequence of 0, 1, 2, 3, 4, 5, 6, 7 where the golden frame refresh period is set as 4, the frames 0, 4, 8 etc will be taken as the golden frames as frame 0 is always a key frame.
-
V4L2_CID_MPEG_VIDEO_VPX_GOLDEN_FRAME_SEL(enum)
-
enum v4l2_vp8_golden_frame_sel -
Selects the golden frame for encoding. Possible values are:
|
|
Use the (n-2)th frame as a golden frame, current frame index being 'n'. |
|
|
Use the previous specific frame indicated by |
-
V4L2_CID_MPEG_VIDEO_VPX_MIN_QP (integer)Minimum quantization parameter for VP8.
-
V4L2_CID_MPEG_VIDEO_VPX_MAX_QP (integer)Maximum quantization parameter for VP8.
-
V4L2_CID_MPEG_VIDEO_VPX_I_FRAME_QP (integer)Quantization parameter for an I frame for VP8.
-
V4L2_CID_MPEG_VIDEO_VPX_P_FRAME_QP (integer)Quantization parameter for a P frame for VP8.
-
V4L2_CID_MPEG_VIDEO_VP8_PROFILE(enum)
-
enum v4l2_mpeg_video_vp8_profile -
This control allows selecting the profile for VP8 encoder. This is also used to enumerate supported profiles by VP8 encoder or decoder. Possible values are:
|
|
Profile 0 |
|
|
Profile 1 |
|
|
Profile 2 |
|
|
Profile 3 |
-
V4L2_CID_MPEG_VIDEO_VP9_PROFILE(enum)
-
enum v4l2_mpeg_video_vp9_profile -
This control allows selecting the profile for VP9 encoder. This is also used to enumerate supported profiles by VP9 encoder or decoder. Possible values are:
|
|
Profile 0 |
|
|
Profile 1 |
|
|
Profile 2 |
|
|
Profile 3 |
V4L2_CID_MPEG_VIDEO_VP9_LEVEL (enum)
-
enum v4l2_mpeg_video_vp9_level -
This control allows selecting the level for VP9 encoder. This is also used to enumerate supported levels by VP9 encoder or decoder. More information can be found at webmproject. Possible values are:
|
|
Level 1 |
|
|
Level 1.1 |
|
|
Level 2 |
|
|
Level 2.1 |
|
|
Level 3 |
|
|
Level 3.1 |
|
|
Level 4 |
|
|
Level 4.1 |
|
|
Level 5 |
|
|
Level 5.1 |
|
|
Level 5.2 |
|
|
Level 6 |
|
|
Level 6.1 |
|
|
Level 6.2 |
High Efficiency Video Coding (HEVC/H.265) Control Reference #
The HEVC/H.265 controls include controls for encoding parameters of HEVC/H.265 video codec.
HEVC/H.265 Control IDs #
-
V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP (integer)Minimum quantization parameter for HEVC. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit.
-
V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP (integer)Maximum quantization parameter for HEVC. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit.
-
V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_QP (integer)Quantization parameter for an I frame for HEVC. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_QP (integer)Quantization parameter for a P frame for HEVC. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_QP (integer)Quantization parameter for a B frame for HEVC. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MIN_QP (integer)Minimum quantization parameter for the HEVC I frame to limit I frame quality to a range. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_HEVC_I_FRAME_MAX_QP (integer)Maximum quantization parameter for the HEVC I frame to limit I frame quality to a range. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MIN_QP (integer)Minimum quantization parameter for the HEVC P frame to limit P frame quality to a range. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_HEVC_P_FRAME_MAX_QP (integer)Maximum quantization parameter for the HEVC P frame to limit P frame quality to a range. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MIN_QP (integer)Minimum quantization parameter for the HEVC B frame to limit B frame quality to a range. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. If V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_HEVC_B_FRAME_MAX_QP (integer)Maximum quantization parameter for the HEVC B frame to limit B frame quality to a range. Valid range: from 0 to 51 for 8 bit and from 0 to 63 for 10 bit. If V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP is also set, the quantization parameter should be chosen to meet both requirements.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_QP (boolean)HIERARCHICAL_QP allows the host to specify the quantization parameter values for each temporal layer through HIERARCHICAL_QP_LAYER. This is valid only if HIERARCHICAL_CODING_LAYER is greater than 1. Setting the control value to 1 enables setting of the QP values for the layers.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_TYPE(enum)
-
enum v4l2_mpeg_video_hevc_hier_coding_type -
Selects the hierarchical coding type for encoding. Possible values are:
|
|
Use the B frame for hierarchical coding. |
|
|
Use the P frame for hierarchical coding. |
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_LAYER (integer)Selects the hierarchical coding layer. In normal encoding (non-hierarchial coding), it should be zero. Possible values are [0, 6]. 0 indicates HIERARCHICAL CODING LAYER 0, 1 indicates HIERARCHICAL CODING LAYER 1 and so on.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_QP (integer)Indicates quantization parameter for hierarchical coding layer 0. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_QP (integer)Indicates quantization parameter for hierarchical coding layer 1. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_QP (integer)Indicates quantization parameter for hierarchical coding layer 2. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_QP (integer)Indicates quantization parameter for hierarchical coding layer 3. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_QP (integer)Indicates quantization parameter for hierarchical coding layer 4. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_QP (integer)Indicates quantization parameter for hierarchical coding layer 5. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_QP (integer)Indicates quantization parameter for hierarchical coding layer 6. Valid range: [V4L2_CID_MPEG_VIDEO_HEVC_MIN_QP, V4L2_CID_MPEG_VIDEO_HEVC_MAX_QP].
-
V4L2_CID_MPEG_VIDEO_HEVC_PROFILE(enum)
-
enum v4l2_mpeg_video_hevc_profile -
Select the desired profile for HEVC encoder.
|
|
Main profile. |
|
|
Main still picture profile. |
|
|
Main 10 profile. |
-
V4L2_CID_MPEG_VIDEO_HEVC_LEVEL(enum)
-
enum v4l2_mpeg_video_hevc_level -
Selects the desired level for HEVC encoder.
|
|
Level 1.0 |
|
|
Level 2.0 |
|
|
Level 2.1 |
|
|
Level 3.0 |
|
|
Level 3.1 |
|
|
Level 4.0 |
|
|
Level 4.1 |
|
|
Level 5.0 |
|
|
Level 5.1 |
|
|
Level 5.2 |
|
|
Level 6.0 |
|
|
Level 6.1 |
|
|
Level 6.2 |
-
V4L2_CID_MPEG_VIDEO_HEVC_FRAME_RATE_RESOLUTION (integer)Indicates the number of evenly spaced subintervals, called ticks, within one second. This is a 16 bit unsigned integer and has a maximum value up to 0xffff and a minimum value of 1.
-
V4L2_CID_MPEG_VIDEO_HEVC_TIER(enum)
-
enum v4l2_mpeg_video_hevc_tier -
TIER_FLAG specifies tiers information of the HEVC encoded picture. Tier were made to deal with applications that differ in terms of maximum bit rate. Setting the flag to 0 selects HEVC tier as Main tier and setting this flag to 1 indicates High tier. High tier is for applications requiring high bit rates.
|
|
Main tier. |
|
|
High tier. |
-
V4L2_CID_MPEG_VIDEO_HEVC_MAX_PARTITION_DEPTH (integer)Selects HEVC maximum coding unit depth.
-
V4L2_CID_MPEG_VIDEO_HEVC_LOOP_FILTER_MODE(enum)
-
enum v4l2_mpeg_video_hevc_loop_filter_mode -
Loop filter mode for HEVC encoder. Possible values are:
|
|
Loop filter is disabled. |
|
|
Loop filter is enabled. |
|
|
Loop filter is disabled at the slice boundary. |
-
V4L2_CID_MPEG_VIDEO_HEVC_LF_BETA_OFFSET_DIV2 (integer)Selects HEVC loop filter beta offset. The valid range is [-6, +6].
-
V4L2_CID_MPEG_VIDEO_HEVC_LF_TC_OFFSET_DIV2 (integer)Selects HEVC loop filter tc offset. The valid range is [-6, +6].
-
V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_TYPE(enum)
-
enum v4l2_mpeg_video_hevc_hier_refresh_type -
Selects refresh type for HEVC encoder. Host has to specify the period into V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_PERIOD.
|
|
Use the B frame for hierarchical coding. |
|
|
Use CRA (Clean Random Access Unit) picture encoding. |
|
|
Use IDR (Instantaneous Decoding Refresh) picture encoding. |
-
V4L2_CID_MPEG_VIDEO_HEVC_REFRESH_PERIOD (integer)Selects the refresh period for HEVC encoder. This specifies the number of I pictures between two CRA/IDR pictures. This is valid only if REFRESH_TYPE is not 0.
-
V4L2_CID_MPEG_VIDEO_HEVC_LOSSLESS_CU (boolean)Indicates HEVC lossless encoding. Setting it to 0 disables lossless encoding. Setting it to 1 enables lossless encoding.
-
V4L2_CID_MPEG_VIDEO_HEVC_CONST_INTRA_PRED (boolean)Indicates constant intra prediction for HEVC encoder. Specifies the constrained intra prediction in which intra largest coding unit (LCU) prediction is performed by using residual data and decoded samples of neighboring intra LCU only. Setting the value to 1 enables constant intra prediction and setting the value to 0 disables constant intra prediction.
-
V4L2_CID_MPEG_VIDEO_HEVC_WAVEFRONT (boolean)Indicates wavefront parallel processing for HEVC encoder. Setting it to 0 disables the feature and setting it to 1 enables the wavefront parallel processing.
-
V4L2_CID_MPEG_VIDEO_HEVC_GENERAL_PB (boolean)Setting the value to 1 enables combination of P and B frame for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_TEMPORAL_ID (boolean)Indicates temporal identifier for HEVC encoder which is enabled by setting the value to 1.
-
V4L2_CID_MPEG_VIDEO_HEVC_STRONG_SMOOTHING (boolean)Indicates bi-linear interpolation is conditionally used in the intra prediction filtering process in the CVS when set to 1. Indicates bi-linear interpolation is not used in the CVS when set to 0.
-
V4L2_CID_MPEG_VIDEO_HEVC_MAX_NUM_MERGE_MV_MINUS1 (integer)Indicates maximum number of merge candidate motion vectors. Values are from 0 to 4.
-
V4L2_CID_MPEG_VIDEO_HEVC_TMV_PREDICTION (boolean)Indicates temporal motion vector prediction for HEVC encoder. Setting it to 1 enables the prediction. Setting it to 0 disables the prediction.
-
V4L2_CID_MPEG_VIDEO_HEVC_WITHOUT_STARTCODE (boolean)Specifies if HEVC generates a stream with a size of the length field instead of start code pattern. The size of the length field is configurable through the V4L2_CID_MPEG_VIDEO_HEVC_SIZE_OF_LENGTH_FIELD control. Setting the value to 0 disables encoding without startcode pattern. Setting the value to 1 will enables encoding without startcode pattern.
V4L2_CID_MPEG_VIDEO_HEVC_SIZE_OF_LENGTH_FIELD (enum)
-
enum v4l2_mpeg_video_hevc_size_of_length_field -
Indicates the size of length field. This is valid when encoding WITHOUT_STARTCODE_ENABLE is enabled.
|
|
Generate start code pattern (Normal). |
|
|
Generate size of length field instead of start code pattern and length is 1. |
|
|
Generate size of length field instead of start code pattern and length is 2. |
|
|
Generate size of length field instead of start code pattern and length is 4. |
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L0_BR (integer)Indicates bit rate for hierarchical coding layer 0 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L1_BR (integer)Indicates bit rate for hierarchical coding layer 1 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L2_BR (integer)Indicates bit rate for hierarchical coding layer 2 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L3_BR (integer)Indicates bit rate for hierarchical coding layer 3 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L4_BR (integer)Indicates bit rate for hierarchical coding layer 4 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L5_BR (integer)Indicates bit rate for hierarchical coding layer 5 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_HEVC_HIER_CODING_L6_BR (integer)Indicates bit rate for hierarchical coding layer 6 for HEVC encoder.
-
V4L2_CID_MPEG_VIDEO_REF_NUMBER_FOR_PFRAMES (integer)Selects number of P reference pictures required for HEVC encoder. P-Frame can use 1 or 2 frames for reference.
-
V4L2_CID_MPEG_VIDEO_PREPEND_SPSPPS_TO_IDR (integer)Indicates whether to generate SPS and PPS at every IDR. Setting it to 0 disables generating SPS and PPS at every IDR. Setting it to one enables generating SPS and PPS at every IDR.
Colorimetry Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Colorimetry class includes controls for High Dynamic Range imaging for representing colors in digital images and video. The controls should be used for video and image encoding and decoding as well as in HDMI receivers and transmitters.
Colorimetry Control IDs #
-
V4L2_CID_COLORIMETRY_CLASS (class)The Colorimetry class descriptor. Calling vidioc_queryctrl for this control will return a description of this control class.
-
V4L2_CID_COLORIMETRY_HDR10_CLL_INFO (struct)The Content Light Level defines upper bounds for the nominal target brightness light level of the pictures.
v4l2_ctrl_hdr10_cll_info
|
__u16 |
|
The upper bound for the maximum light level among all individual samples for the pictures of a video sequence, cd/m2. When equal to 0 no such upper bound is present. |
|
__u16 |
|
The upper bound for the maximum average light level among the samples for any individual picture of a video sequence, cd/m2. When equal to 0 no such upper bound is present. |
-
V4L2_CID_COLORIMETRY_HDR10_MASTERING_DISPLAY (struct)The mastering display defines the color volume (the color primaries, white point and luminance range) of a display considered to be the mastering display for the current video content.
v4l2_ctrl_hdr10_mastering_display
|
__u16 |
|
Specifies the normalized x chromaticity coordinate of the color primary component c of the mastering display in increments of 0.00002. For describing the mastering display that uses Red, Green and Blue color primaries, index value c equal to 0 corresponds to the Green primary, c equal to 1 corresponds to Blue primary and c equal to 2 corresponds to the Red color primary. |
|
__u16 |
|
Specifies the normalized y chromaticity coordinate of the color primary component c of the mastering display in increments of 0.00002. For describing the mastering display that uses Red, Green and Blue color primaries, index value c equal to 0 corresponds to the Green primary, c equal to 1 corresponds to Blue primary and c equal to 2 corresponds to Red color primary. |
|
__u16 |
|
Specifies the normalized x chromaticity coordinate of the white point of the mastering display in increments of 0.00002. |
|
__u16 |
|
Specifies the normalized y chromaticity coordinate of the white point of the mastering display in increments of 0.00002. |
|
__u32 |
|
Specifies the nominal maximum display luminance of the mastering display in units of 0.0001 cd/m2. |
|
__u32 |
|
specifies the nominal minimum display luminance of the mastering display in units of 0.0001 cd/m2. |
Detect Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Detect class includes controls for common features of various motion or object detection capable devices.
Detect Control IDs #
-
V4L2_CID_DETECT_CLASS (class)The Detect class descriptor. Calling vidioc_queryctrl for this control will return a description of this control class.
-
V4L2_CID_DETECT_MD_MODE (menu)Sets the motion detection mode.
|
|
Disable motion detection. |
|
|
Use a single motion detection threshold. |
|
|
The image is divided into a grid, each cell with its own motion detection threshold. These thresholds are set through the |
|
|
The image is divided into a grid, each cell with its own region value that specifies which per-region motion detection thresholds should be used. Each region has its own thresholds. How these per-region thresholds are set up is driver-specific. The region values for the grid are set through the |
-
V4L2_CID_DETECT_MD_GLOBAL_THRESHOLD (integer)Sets the global motion detection threshold to be used with the
V4L2_DETECT_MD_MODE_GLOBALmotion detection mode. -
V4L2_CID_DETECT_MD_THRESHOLD_GRID (__u16 matrix)Sets the motion detection thresholds for each cell in the grid. To be used with the
V4L2_DETECT_MD_MODE_THRESHOLD_GRIDmotion detection mode. Matrix element (0, 0) represents the cell at the top-left of the grid. -
V4L2_CID_DETECT_MD_REGION_GRID (__u8 matrix)Sets the motion detection region value for each cell in the grid. To be used with the
V4L2_DETECT_MD_MODE_REGION_GRIDmotion detection mode. Matrix element (0, 0) represents the cell at the top-left of the grid.
Digital Video Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Digital Video control class is intended to control receivers and transmitters for VGA, DVI (Digital Visual Interface), HDMI (HDMI) and DisplayPort (DP). These controls are generally expected to be private to the receiver or transmitter subdevice that implements them, so they are only exposed on the /dev/v4l-subdev* device node.
These pads appear in several of the controls in this section as bitmasks, one bit for each pad. Bit 0 corresponds to pad 0, bit 1 to pad 1, etc. The maximum value of the control is the set of valid pads.
Digital Video Control IDs #
-
V4L2_CID_DV_CLASS (class)The Digital Video class descriptor.
-
V4L2_CID_DV_TX_HOTPLUG (bitmask)Many connectors have a hotplug pin which is high if EDID information is available from the source. This control shows the state of the hotplug pin as seen by the transmitter. Each bit corresponds to an output pad on the transmitter. If an output pad does not have an associated hotplug pin, then the bit for that pad will be 0. This read-only control is applicable to DVI-D, HDMI and DisplayPort connectors.
-
V4L2_CID_DV_TX_RXSENSE (bitmask)Rx Sense is the detection of pull-ups on the TMDS clock lines. This normally means that the sink has left/entered standby (i.e. the transmitter can sense that the receiver is ready to receive video). Each bit corresponds to an output pad on the transmitter. If an output pad does not have an associated Rx Sense, then the bit for that pad will be 0. This read-only control is applicable to DVI-D and HDMI devices.
-
V4L2_CID_DV_TX_EDID_PRESENT (bitmask)When the transmitter sees the hotplug signal from the receiver it will attempt to read the EDID. If set, then the transmitter has read at least the first block (= 128 bytes). Each bit corresponds to an output pad on the transmitter. If an output pad does not support EDIDs, then the bit for that pad will be 0. This read-only control is applicable to VGA, DVI-A/D, HDMI and DisplayPort connectors.
-
V4L2_CID_DV_TX_MODE(enum)
-
enum v4l2_dv_tx_mode -
HDMI transmitters can transmit in DVI-D mode (just video) or in HDMI mode (video + audio + auxiliary data). This control selects which mode to use: V4L2_DV_TX_MODE_DVI_D or V4L2_DV_TX_MODE_HDMI. This control is applicable to HDMI connectors.
-
V4L2_CID_DV_TX_RGB_RANGE(enum)
-
enum v4l2_dv_rgb_range -
Select the quantization range for RGB output. V4L2_DV_RANGE_AUTO follows the RGB quantization range specified in the standard for the video interface (ie. CEA-861-E for HDMI). V4L2_DV_RANGE_LIMITED and V4L2_DV_RANGE_FULL override the standard to be compatible with sinks that have not implemented the standard correctly (unfortunately quite common for HDMI and DVI-D). Full range allows all possible values to be used whereas limited range sets the range to (16 << (N-8)) - (235 << (N-8)) where N is the number of bits per component. This control is applicable to VGA, DVI-A/D, HDMI and DisplayPort connectors.
-
V4L2_CID_DV_TX_IT_CONTENT_TYPE(enum)
-
enum v4l2_dv_it_content_type -
Configures the IT Content Type of the transmitted video. This information is sent over HDMI and DisplayPort connectors as part of the AVI InfoFrame. The term 'IT Content' is used for content that originates from a computer as opposed to content from a TV broadcast or an analog source. The enum v4l2_dv_it_content_type defines the possible content types:
|
|
Graphics content. Pixel data should be passed unfiltered and without analog reconstruction. |
|
|
Photo content. The content is derived from digital still pictures. The content should be passed through with minimal scaling and picture enhancements. |
|
|
Cinema content. |
|
|
Game content. Audio and video latency should be minimized. |
|
|
No IT Content information is available and the ITC bit in the AVI InfoFrame is set to 0. |
-
V4L2_CID_DV_RX_POWER_PRESENT (bitmask)Detects whether the receiver receives power from the source (e.g. HDMI carries 5V on one of the pins). This is often used to power an eeprom which contains EDID information, such that the source can read the EDID even if the sink is in standby/power off. Each bit corresponds to an input pad on the receiver. If an input pad cannot detect whether power is present, then the bit for that pad will be 0. This read-only control is applicable to DVI-D, HDMI and DisplayPort connectors.
-
V4L2_CID_DV_RX_RGB_RANGE(enum)
-
enum v4l2_dv_rgb_range -
Select the quantization range for RGB input. V4L2_DV_RANGE_AUTO follows the RGB quantization range specified in the standard for the video interface (ie. CEA-861-E for HDMI). V4L2_DV_RANGE_LIMITED and V4L2_DV_RANGE_FULL override the standard to be compatible with sources that have not implemented the standard correctly (unfortunately quite common for HDMI and DVI-D). Full range allows all possible values to be used whereas limited range sets the range to (16 << (N-8)) - (235 << (N-8)) where N is the number of bits per component. This control is applicable to VGA, DVI-A/D, HDMI and DisplayPort connectors.
-
V4L2_CID_DV_RX_IT_CONTENT_TYPE(enum)
-
enum v4l2_dv_it_content_type -
Reads the IT Content Type of the received video. This information is sent over HDMI and DisplayPort connectors as part of the AVI InfoFrame. The term 'IT Content' is used for content that originates from a computer as opposed to content from a TV broadcast or an analog source. See
V4L2_CID_DV_TX_IT_CONTENT_TYPEfor the available content types.
Flash Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The V4L2 flash controls are intended to provide generic access to flash controller devices. Flash controller devices are typically used in digital cameras.
The interface can support both LED and xenon flash devices. As of writing this, there is no xenon flash driver using this interface.
Supported use cases #
Unsynchronised LED flash (software strobe) #
Unsynchronised LED flash is controlled directly by the host as the sensor. The flash must be enabled by the host before the exposure of the image starts and disabled once it ends. The host is fully responsible for the timing of the flash.
Example of such device: Nokia N900.
Synchronised LED flash (hardware strobe) #
The synchronised LED flash is pre-programmed by the host (power and timeout) but controlled by the sensor through a strobe signal from the sensor to the flash.
The sensor controls the flash duration and timing. This information typically must be made available to the sensor.
LED flash as torch #
LED flash may be used as torch in conjunction with another use case involving camera or individually.
Flash Control IDs #
-
V4L2_CID_FLASH_CLASS (class)The FLASH class descriptor.
-
V4L2_CID_FLASH_LED_MODE (menu)Defines the mode of the flash LED, the high-power white LED attached to the flash controller. Setting this control may not be possible in presence of some faults. See V4L2_CID_FLASH_FAULT.
|
|
Off. |
|
|
Flash mode. |
|
|
Torch mode. See V4L2_CID_FLASH_TORCH_INTENSITY. |
-
V4L2_CID_FLASH_STROBE_SOURCE (menu)Defines the source of the flash LED strobe.
|
|
The flash strobe is triggered by using the V4L2_CID_FLASH_STROBE control. |
|
|
The flash strobe is triggered by an external source. Typically this is a sensor, which makes it possible to synchronise the flash strobe start to exposure start. This method of controlling flash LED strobe has two additional prerequisites: the strobe source's strobe output must be enabled (if available) and the flash controller's flash LED mode must be set to |
-
V4L2_CID_FLASH_STROBE (button)Strobe flash. Valid when V4L2_CID_FLASH_LED_MODE is set to V4L2_FLASH_LED_MODE_FLASH and V4L2_CID_FLASH_STROBE_SOURCE is set to V4L2_FLASH_STROBE_SOURCE_SOFTWARE. Setting this control may not be possible in presence of some faults. See V4L2_CID_FLASH_FAULT.
-
V4L2_CID_FLASH_STROBE_STOP (button)Stop flash strobe immediately.
-
V4L2_CID_FLASH_STROBE_STATUS (boolean)Strobe status: whether the flash is strobing at the moment or not. This is a read-only control.
-
V4L2_CID_FLASH_TIMEOUT (integer)Hardware timeout for flash. The flash strobe is stopped after this period of time has passed from the start of the strobe.
-
V4L2_CID_FLASH_INTENSITY (integer)Intensity of the flash strobe when the flash LED is in flash mode (V4L2_FLASH_LED_MODE_FLASH). The unit should be milliamps (mA) if possible.
-
V4L2_CID_FLASH_TORCH_INTENSITY (integer)Intensity of the flash LED in torch mode (V4L2_FLASH_LED_MODE_TORCH). The unit should be milliamps (mA) if possible. Setting this control may not be possible in presence of some faults. See V4L2_CID_FLASH_FAULT.
-
V4L2_CID_FLASH_INDICATOR_INTENSITY (integer)Intensity of the indicator LED. The indicator LED may be fully independent of the flash LED. The unit should be microamps (uA) if possible.
-
V4L2_CID_FLASH_FAULT (bitmask)Faults related to the flash. The faults tell about specific problems in the flash chip itself or the LEDs attached to it. Faults may prevent further use of some of the flash controls. In particular, V4L2_CID_FLASH_LED_MODE is set to V4L2_FLASH_LED_MODE_NONE if the fault affects the flash LED. Exactly which faults have such an effect is chip dependent. Reading the faults resets the control and returns the chip to a usable state if possible.
|
|
Flash controller voltage to the flash LED has exceeded the limit specific to the flash controller. |
|
|
The flash strobe was still on when the timeout set by the user --- V4L2_CID_FLASH_TIMEOUT control --- has expired. Not all flash controllers may set this in all such conditions. |
|
|
The flash controller has overheated. |
|
|
The short circuit protection of the flash controller has been triggered. |
|
|
Current in the LED power supply has exceeded the limit specific to the flash controller. |
|
|
The flash controller has detected a short or open circuit condition on the indicator LED. |
|
|
Flash controller voltage to the flash LED has been below the minimum limit specific to the flash controller. |
|
|
The input voltage of the flash controller is below the limit under which strobing the flash at full current will not be possible.The condition persists until this flag is no longer set. |
|
|
The temperature of the LED has exceeded its allowed upper limit. |
-
V4L2_CID_FLASH_CHARGE (boolean)Enable or disable charging of the xenon flash capacitor.
-
V4L2_CID_FLASH_READY (boolean)Is the flash ready to strobe? Xenon flashes require their capacitors charged before strobing. LED flashes often require a cooldown period after strobe during which another strobe will not be possible. This is a read-only control.
-
V4L2_CID_FLASH_DURATION (integer)Duration of the flash strobe pulse generated by the strobe source, when using external strobe. This control shall be implemented by the device generating the hardware flash strobe signal, typically a camera sensor, connected to a flash controller.
The flash controllers strobe source must be configured to
V4L2_FLASH_STROBE_SOURCE_EXTERNALfor this mode of operation. For more details please also take a look at the documentation there.The unit should be microseconds (µs) if possible.
-
V4L2_CID_FLASH_STROBE_OE (boolean)Enables the output of a hardware strobe signal from the strobe source, when using external strobe. This control shall be implemented by the device generating the hardware flash strobe signal, typically a camera sensor, connected to a flash controller.
Provided the signal generating device driver supports it, the length of the strobe signal can be configured by adjusting its flash duration.
The flash controllers strobe source must be configured to
V4L2_FLASH_STROBE_SOURCE_EXTERNALfor this mode of operation. For more details please also take a look at the documentation there.
FM Receiver Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The FM Receiver (FM_RX) class includes controls for common features of FM Reception capable devices.
FM_RX Control IDs #
-
V4L2_CID_FM_RX_CLASS (class)The FM_RX class descriptor. Calling vidioc_queryctrl for this control will return a description of this control class.
-
V4L2_CID_RDS_RECEPTION (boolean)Enables/disables RDS reception by the radio tuner
-
V4L2_CID_RDS_RX_PTY (integer)Gets RDS Programme Type field. This encodes up to 31 pre-defined programme types.
-
V4L2_CID_RDS_RX_PS_NAME (string)Gets the Programme Service name (PS_NAME). It is intended for static display on a receiver. It is the primary aid to listeners in programme service identification and selection. In Annex E of IEC 62106, the RDS specification, there is a full description of the correct character encoding for Programme Service name strings. Also from RDS specification, PS is usually a single eight character text. However, it is also possible to find receivers which can scroll strings sized as 8 x N characters. So, this control must be configured with steps of 8 characters. The result is it must always contain a string with size multiple of 8.
-
V4L2_CID_RDS_RX_RADIO_TEXT (string)Gets the Radio Text info. It is a textual description of what is being broadcasted. RDS Radio Text can be applied when broadcaster wishes to transmit longer PS names, programme-related information or any other text. In these cases, RadioText can be used in addition to
V4L2_CID_RDS_RX_PS_NAME. The encoding for Radio Text strings is also fully described in Annex E of IEC 62106. The length of Radio Text strings depends on which RDS Block is being used to transmit it, either 32 (2A block) or 64 (2B block). However, it is also possible to find receivers which can scroll strings sized as 32 x N or 64 x N characters. So, this control must be configured with steps of 32 or 64 characters. The result is it must always contain a string with size multiple of 32 or 64. -
V4L2_CID_RDS_RX_TRAFFIC_ANNOUNCEMENT (boolean)If set, then a traffic announcement is in progress.
-
V4L2_CID_RDS_RX_TRAFFIC_PROGRAM (boolean)If set, then the tuned programme carries traffic announcements.
-
V4L2_CID_RDS_RX_MUSIC_SPEECH (boolean)If set, then this channel broadcasts music. If cleared, then it broadcasts speech. If the transmitter doesn't make this distinction, then it will be set.
-
V4L2_CID_TUNE_DEEMPHASIS (enum)Configures the de-emphasis value for reception. A de-emphasis filter is applied to the broadcast to accentuate the high audio frequencies. Depending on the region, a time constant of either 50 or 75 microseconds is used. The enum v4l2_deemphasis defines possible values for de-emphasis. They are:
|
|
No de-emphasis is applied. |
|
|
A de-emphasis of 50 uS is used. |
|
|
A de-emphasis of 75 uS is used. |
FM Transmitter Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The FM Transmitter (FM_TX) class includes controls for common features of FM transmissions capable devices. Currently this class includes parameters for audio compression, pilot tone generation, audio deviation limiter, RDS transmission and tuning power features.
FM_TX Control IDs #
-
V4L2_CID_FM_TX_CLASS (class)The FM_TX class descriptor. Calling vidioc_queryctrl for this control will return a description of this control class.
-
V4L2_CID_RDS_TX_DEVIATION (integer)Configures RDS signal frequency deviation level in Hz. The range and step are driver-specific.
-
V4L2_CID_RDS_TX_PI (integer)Sets the RDS Programme Identification field for transmission.
-
V4L2_CID_RDS_TX_PTY (integer)Sets the RDS Programme Type field for transmission. This encodes up to 31 pre-defined programme types.
-
V4L2_CID_RDS_TX_PS_NAME (string)Sets the Programme Service name (PS_NAME) for transmission. It is intended for static display on a receiver. It is the primary aid to listeners in programme service identification and selection. In Annex E of IEC 62106, the RDS specification, there is a full description of the correct character encoding for Programme Service name strings. Also from RDS specification, PS is usually a single eight character text. However, it is also possible to find receivers which can scroll strings sized as 8 x N characters. So, this control must be configured with steps of 8 characters. The result is it must always contain a string with size multiple of 8.
-
V4L2_CID_RDS_TX_RADIO_TEXT (string)Sets the Radio Text info for transmission. It is a textual description of what is being broadcasted. RDS Radio Text can be applied when broadcaster wishes to transmit longer PS names, programme-related information or any other text. In these cases, RadioText should be used in addition to
V4L2_CID_RDS_TX_PS_NAME. The encoding for Radio Text strings is also fully described in Annex E of IEC 62106. The length of Radio Text strings depends on which RDS Block is being used to transmit it, either 32 (2A block) or 64 (2B block). However, it is also possible to find receivers which can scroll strings sized as 32 x N or 64 x N characters. So, this control must be configured with steps of 32 or 64 characters. The result is it must always contain a string with size multiple of 32 or 64. -
V4L2_CID_RDS_TX_MONO_STEREO (boolean)Sets the Mono/Stereo bit of the Decoder Identification code. If set, then the audio was recorded as stereo.
-
V4L2_CID_RDS_TX_ARTIFICIAL_HEAD (boolean)Sets the Artificial Head bit of the Decoder Identification code. If set, then the audio was recorded using an artificial head.
-
V4L2_CID_RDS_TX_COMPRESSED (boolean)Sets the Compressed bit of the Decoder Identification code. If set, then the audio is compressed.
-
V4L2_CID_RDS_TX_DYNAMIC_PTY (boolean)Sets the Dynamic PTY bit of the Decoder Identification code. If set, then the PTY code is dynamically switched.
-
V4L2_CID_RDS_TX_TRAFFIC_ANNOUNCEMENT (boolean)If set, then a traffic announcement is in progress.
-
V4L2_CID_RDS_TX_TRAFFIC_PROGRAM (boolean)If set, then the tuned programme carries traffic announcements.
-
V4L2_CID_RDS_TX_MUSIC_SPEECH (boolean)If set, then this channel broadcasts music. If cleared, then it broadcasts speech. If the transmitter doesn't make this distinction, then it should be set.
-
V4L2_CID_RDS_TX_ALT_FREQS_ENABLE (boolean)If set, then transmit alternate frequencies.
-
V4L2_CID_RDS_TX_ALT_FREQS (__u32 array)The alternate frequencies in kHz units. The RDS standard allows for up to 25 frequencies to be defined. Drivers may support fewer frequencies so check the array size.
-
V4L2_CID_AUDIO_LIMITER_ENABLED (boolean)Enables or disables the audio deviation limiter feature. The limiter is useful when trying to maximize the audio volume, minimize receiver-generated distortion and prevent overmodulation.
-
V4L2_CID_AUDIO_LIMITER_RELEASE_TIME (integer)Sets the audio deviation limiter feature release time. Unit is in microseconds. Step and range are driver-specific.
-
V4L2_CID_AUDIO_LIMITER_DEVIATION (integer)Configures audio frequency deviation level in Hz. The range and step are driver-specific.
-
V4L2_CID_AUDIO_COMPRESSION_ENABLED (boolean)Enables or disables the audio compression feature. This feature amplifies signals below the threshold by a fixed gain and compresses audio signals above the threshold by the ratio of Threshold/(Gain + Threshold).
-
V4L2_CID_AUDIO_COMPRESSION_GAIN (integer)Sets the gain for audio compression feature. It is a dB value. The range and step are driver-specific.
-
V4L2_CID_AUDIO_COMPRESSION_THRESHOLD (integer)Sets the threshold level for audio compression feature. It is a dB value. The range and step are driver-specific.
-
V4L2_CID_AUDIO_COMPRESSION_ATTACK_TIME (integer)Sets the attack time for audio compression feature. It is a microseconds value. The range and step are driver-specific.
-
V4L2_CID_AUDIO_COMPRESSION_RELEASE_TIME (integer)Sets the release time for audio compression feature. It is a microseconds value. The range and step are driver-specific.
-
V4L2_CID_PILOT_TONE_ENABLED (boolean)Enables or disables the pilot tone generation feature.
-
V4L2_CID_PILOT_TONE_DEVIATION (integer)Configures pilot tone frequency deviation level. Unit is in Hz. The range and step are driver-specific.
-
V4L2_CID_PILOT_TONE_FREQUENCY (integer)Configures pilot tone frequency value. Unit is in Hz. The range and step are driver-specific.
-
V4L2_CID_TUNE_PREEMPHASIS (enum)Configures the pre-emphasis value for broadcasting. A pre-emphasis filter is applied to the broadcast to accentuate the high audio frequencies. Depending on the region, a time constant of either 50 or 75 microseconds is used. The enum v4l2_preemphasis defines possible values for pre-emphasis. They are:
|
|
No pre-emphasis is applied. |
|
|
A pre-emphasis of 50 uS is used. |
|
|
A pre-emphasis of 75 uS is used. |
-
V4L2_CID_TUNE_POWER_LEVEL (integer)Sets the output power level for signal transmission. Unit is in dBuV. Range and step are driver-specific.
-
V4L2_CID_TUNE_ANTENNA_CAPACITOR (integer)This selects the value of antenna tuning capacitor manually or automatically if set to zero. Unit, range and step are driver-specific.
For more details about RDS specification, refer to IEC 62106 document, from CENELEC.
Image Process Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Image Process control class is intended for low-level control of image processing functions. Unlike V4L2_CID_IMAGE_SOURCE_CLASS, the controls in this class affect processing the image, and do not control capturing of it.
Image Process Control IDs #
-
V4L2_CID_IMAGE_PROC_CLASS (class)The IMAGE_PROC class descriptor.
-
V4L2_CID_LINK_FREQ (integer menu)The frequency of the data bus (e.g. parallel or CSI-2).
-
V4L2_CID_PIXEL_RATE (64-bit integer)Pixel sampling rate in the device's pixel array. This control is read-only and its unit is pixels / second.
Some devices use horizontal and vertical blanking to configure the frame rate. The frame rate can be calculated from the pixel rate, analogue crop rectangle as well as horizontal and vertical blanking. The pixel rate control may be present in a different sub-device than the blanking controls and the analogue crop rectangle configuration.
The configuration of the frame rate is performed by selecting the desired horizontal and vertical blanking. The unit of this control is Hz.
-
V4L2_CID_TEST_PATTERN (menu)Some capture/display/sensor devices have the capability to generate test pattern images. These hardware specific test patterns can be used to test if a device is working properly.
-
V4L2_CID_DEINTERLACING_MODE (menu)The video deinterlacing mode (such as Bob, Weave, ...). The menu items are driver specific and are documented in Video4Linux (V4L) driver-specific documentation.
-
V4L2_CID_DIGITAL_GAIN (integer)Digital gain is the value by which all colour components are multiplied by. Typically the digital gain applied is the control value divided by e.g. 0x100, meaning that to get no digital gain the control value needs to be 0x100. The no-gain configuration is also typically the default.
Image Source Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The Image Source control class is intended for low-level control of image source devices such as image sensors. The devices feature an analogue to digital converter and a bus transmitter to transmit the image data out of the device.
Image Source Control IDs #
-
V4L2_CID_IMAGE_SOURCE_CLASS (class)The IMAGE_SOURCE class descriptor.
-
V4L2_CID_VBLANK (integer)Vertical blanking. The idle period after every frame during which no image data is produced. The unit of vertical blanking is a line. Every line has length of the image width plus horizontal blanking at the pixel rate defined by
V4L2_CID_PIXEL_RATEcontrol in the same sub-device. -
V4L2_CID_HBLANK (integer)Horizontal blanking. The idle period after every line of image data during which no image data is produced. The unit of horizontal blanking is pixels.
-
V4L2_CID_ANALOGUE_GAIN (integer)Analogue gain is gain affecting all colour components in the pixel matrix. The gain operation is performed in the analogue domain before A/D conversion.
-
V4L2_CID_TEST_PATTERN_RED (integer)Test pattern red colour component.
-
V4L2_CID_TEST_PATTERN_GREENR (integer)Test pattern green (next to red) colour component.
-
V4L2_CID_TEST_PATTERN_BLUE (integer)Test pattern blue colour component.
-
V4L2_CID_TEST_PATTERN_GREENB (integer)Test pattern green (next to blue) colour component.
-
V4L2_CID_UNIT_CELL_SIZE (struct)This control returns the unit cell size in nanometers. The struct
v4l2_areaprovides the width and the height in separate fields to take into consideration asymmetric pixels. This control does not take into consideration any possible hardware binning. The unit cell consists of the whole area of the pixel, sensitive and non-sensitive. This control is required for automatic calibration of sensors/cameras.
v4l2_area
|
__u32 |
|
Width of the area. |
|
__u32 |
|
Height of the area. |
-
V4L2_CID_NOTIFY_GAINS (integer array)The sensor is notified what gains will be applied to the different colour channels by subsequent processing (such as by an ISP). The sensor is merely informed of these values in case it performs processing that requires them, but it does not apply them itself to the output pixels.
Currently it is defined only for Bayer sensors, and is an array control taking 4 gain values, being the gains for each of the Bayer channels. The gains are always in the order B, Gb, Gr and R, irrespective of the exact Bayer order of the sensor itself.
The use of an array allows this control to be extended to sensors with, for example, non-Bayer CFAs (colour filter arrays).
The units for the gain values are linear, with the default value representing a gain of exactly 1.0. For example, if this default value is reported as being (say) 128, then a value of 192 would represent a gain of exactly 1.5.
JPEG Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The JPEG class includes controls for common features of JPEG encoders and decoders. Currently it includes features for codecs implementing progressive baseline DCT compression process with Huffman entropy coding.
JPEG Control IDs #
-
V4L2_CID_JPEG_CLASS (class)The JPEG class descriptor. Calling vidioc_queryctrl for this control will return a description of this control class.
-
V4L2_CID_JPEG_CHROMA_SUBSAMPLING (menu)The chroma subsampling factors describe how each component of an input image is sampled, in respect to maximum sample rate in each spatial dimension. See ITU-T.81, clause A.1.1. for more details. The
V4L2_CID_JPEG_CHROMA_SUBSAMPLINGcontrol determines how Cb and Cr components are downsampled after converting an input image from RGB to Y'CbCr color space.
|
|
No chroma subsampling, each pixel has Y, Cr and Cb values. |
|
|
Horizontally subsample Cr, Cb components by a factor of 2. |
|
|
Subsample Cr, Cb components horizontally and vertically by 2. |
|
|
Horizontally subsample Cr, Cb components by a factor of 4. |
|
|
Subsample Cr, Cb components horizontally by 4 and vertically by 2. |
|
|
Use only luminance component. |
-
V4L2_CID_JPEG_RESTART_INTERVAL (integer)The restart interval determines an interval of inserting RSTm markers (m = 0..7). The purpose of these markers is to additionally reinitialize the encoder process, in order to process blocks of an image independently. For the lossy compression processes the restart interval unit is MCU (Minimum Coded Unit) and its value is contained in DRI (Define Restart Interval) marker. If
V4L2_CID_JPEG_RESTART_INTERVALcontrol is set to 0, DRI and RSTm markers will not be inserted.
-
V4L2_CID_JPEG_COMPRESSION_QUALITY (integer)Determines trade-off between image quality and size. It provides simpler method for applications to control image quality, without a need for direct reconfiguration of luminance and chrominance quantization tables. In cases where a driver uses quantization tables configured directly by an application, using interfaces defined elsewhere,
V4L2_CID_JPEG_COMPRESSION_QUALITYcontrol should be set by driver to 0.The value range of this control is driver-specific. Only positive, non-zero values are meaningful. The recommended range is 1 - 100, where larger values correspond to better image quality.
-
V4L2_CID_JPEG_ACTIVE_MARKER (bitmask)Specify which JPEG markers are included in compressed stream. This control is valid only for encoders.
|
|
Application data segment APP0. |
|
|
Application data segment APP1. |
|
|
Comment segment. |
|
|
Quantization tables segment. |
|
|
Huffman tables segment. |
For more details about JPEG specification, refer to ITU-T.81, JFIF, W3C JPEG JFIF.
RF Tuner Control Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The RF Tuner (RF_TUNER) class includes controls for common features of devices having RF tuner.
In this context, RF tuner is radio receiver circuit between antenna and demodulator. It receives radio frequency (RF) from the antenna and converts that received signal to lower intermediate frequency (IF) or baseband frequency (BB). Tuners that could do baseband output are often called Zero-IF tuners. Older tuners were typically simple PLL tuners inside a metal box, while newer ones are highly integrated chips without a metal box "silicon tuners". These controls are mostly applicable for new feature rich silicon tuners, just because older tuners does not have much adjustable features.
For more information about RF tuners see Tuner (radio) and RF front end from Wikipedia.
RF_TUNER Control IDs #
-
V4L2_CID_RF_TUNER_CLASS (class)The RF_TUNER class descriptor. Calling vidioc_queryctrl for this control will return a description of this control class.
-
V4L2_CID_RF_TUNER_BANDWIDTH_AUTO (boolean)Enables/disables tuner radio channel bandwidth configuration. In automatic mode bandwidth configuration is performed by the driver.
-
V4L2_CID_RF_TUNER_BANDWIDTH (integer)Filter(s) on tuner signal path are used to filter signal according to receiving party needs. Driver configures filters to fulfill desired bandwidth requirement. Used when V4L2_CID_RF_TUNER_BANDWIDTH_AUTO is not set. Unit is in Hz. The range and step are driver-specific.
-
V4L2_CID_RF_TUNER_LNA_GAIN_AUTO (boolean)Enables/disables LNA automatic gain control (AGC)
-
V4L2_CID_RF_TUNER_MIXER_GAIN_AUTO (boolean)Enables/disables mixer automatic gain control (AGC)
-
V4L2_CID_RF_TUNER_IF_GAIN_AUTO (boolean)Enables/disables IF automatic gain control (AGC)
-
V4L2_CID_RF_TUNER_RF_GAIN (integer)The RF amplifier is the very first amplifier on the receiver signal path, just right after the antenna input. The difference between the LNA gain and the RF gain in this document is that the LNA gain is integrated in the tuner chip while the RF gain is a separate chip. There may be both RF and LNA gain controls in the same device. The range and step are driver-specific.
-
V4L2_CID_RF_TUNER_LNA_GAIN (integer)LNA (low noise amplifier) gain is first gain stage on the RF tuner signal path. It is located very close to tuner antenna input. Used when
V4L2_CID_RF_TUNER_LNA_GAIN_AUTOis not set. SeeV4L2_CID_RF_TUNER_RF_GAINto understand how RF gain and LNA gain differs from the each others. The range and step are driver-specific. -
V4L2_CID_RF_TUNER_MIXER_GAIN (integer)Mixer gain is second gain stage on the RF tuner signal path. It is located inside mixer block, where RF signal is down-converted by the mixer. Used when
V4L2_CID_RF_TUNER_MIXER_GAIN_AUTOis not set. The range and step are driver-specific. -
V4L2_CID_RF_TUNER_IF_GAIN (integer)IF gain is last gain stage on the RF tuner signal path. It is located on output of RF tuner. It controls signal level of intermediate frequency output or baseband output. Used when
V4L2_CID_RF_TUNER_IF_GAIN_AUTOis not set. The range and step are driver-specific. -
V4L2_CID_RF_TUNER_PLL_LOCK (boolean)Is synthesizer PLL locked? RF tuner is receiving given frequency when that control is set. This is a read-only control.
Extended Controls API
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Introduction #
The control mechanism as originally designed was meant to be used for user settings (brightness, saturation, etc). However, it turned out to be a very useful model for implementing more complicated driver APIs where each driver implements only a subset of a larger API.
The MPEG encoding API was the driving force behind designing and implementing this extended control mechanism: the MPEG standard is quite large and the currently supported hardware MPEG encoders each only implement a subset of this standard. Further more, many parameters relating to how the video is encoded into an MPEG stream are specific to the MPEG encoding chip since the MPEG standard only defines the format of the resulting MPEG stream, not how the video is actually encoded into that format.
Unfortunately, the original control API lacked some features needed for these new uses and so it was extended into the (not terribly originally named) extended control API.
Even though the MPEG encoding API was the first effort to use the Extended Control API, nowadays there are also other classes of Extended Controls, such as Camera Controls and FM Transmitter Controls. The Extended Controls API as well as all Extended Controls classes are described in the following text.
The Extended Control API #
Three new ioctls are available: VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS. These ioctls act on arrays of controls (as opposed to the VIDIOC_G_CTRL and VIDIOC_S_CTRL ioctls that act on a single control). This is needed since it is often required to atomically change several controls at once.
Each of the new ioctls expects a pointer to a struct v4l2_ext_controls. This structure contains a pointer to the control array, a count of the number of controls in that array and a control class. Control classes are used to group similar controls into a single class. For example, control class V4L2_CTRL_CLASS_USER contains all user controls (i. e. all controls that can also be set using the old VIDIOC_S_CTRL ioctl). Control class V4L2_CTRL_CLASS_CODEC contains controls relating to codecs.
All controls in the control array must belong to the specified control class. An error is returned if this is not the case.
It is also possible to use an empty control array (count == 0) to check whether the specified control class is supported.
The control array is a struct v4l2_ext_control array. The struct v4l2_ext_control is very similar to struct v4l2_control, except for the fact that it also allows for 64-bit values and pointers to be passed.
Since the struct v4l2_ext_control supports pointers it is now also possible to have controls with compound types such as N-dimensional arrays and/or structures. You need to specify the V4L2_CTRL_FLAG_NEXT_COMPOUND when enumerating controls to actually be able to see such compound controls. In other words, these controls with compound types should only be used programmatically.
Since such compound controls need to expose more information about themselves than is possible with VIDIOC_QUERYCTRL the VIDIOC_QUERY_EXT_CTRL ioctl was added. In particular, this ioctl gives the dimensions of the N-dimensional array if this control consists of more than one element.
All controls use machine endianness.
Enumerating Extended Controls #
The recommended way to enumerate over the extended controls is by using vidioc_queryctrl in combination with the V4L2_CTRL_FLAG_NEXT_CTRL flag:
struct v4l2_queryctrl qctrl;
qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
while
The initial control ID is set to 0 ORed with the V4L2_CTRL_FLAG_NEXT_CTRL flag. The VIDIOC_QUERYCTRL ioctl will return the first control with a higher ID than the specified one. When no such controls are found an error is returned.
If you want to get all controls within a specific control class, then you can set the initial qctrl.id value to the control class and add an extra check to break out of the loop when a control of another control class is found:
qctrl.id = V4L2_CTRL_CLASS_CODEC | V4L2_CTRL_FLAG_NEXT_CTRL;
while
The 32-bit qctrl.id value is subdivided into three bit ranges: the top 4 bits are reserved for flags (e. g. V4L2_CTRL_FLAG_NEXT_CTRL) and are not actually part of the ID. The remaining 28 bits form the control ID, of which the most significant 12 bits define the control class and the least significant 16 bits identify the control within the control class. It is guaranteed that these last 16 bits are always non-zero for controls. The range of 0x1000 and up are reserved for driver-specific controls. The macro V4L2_CTRL_ID2CLASS(id) returns the control class ID based on a control ID.
If the driver does not support extended controls, then VIDIOC_QUERYCTRL will fail when used in combination with V4L2_CTRL_FLAG_NEXT_CTRL. In that case the old method of enumerating control should be used (see Example: Enumerating all controls). But if it is supported, then it is guaranteed to enumerate over all controls, including driver-private controls.
Creating Control Panels #
It is possible to create control panels for a graphical user interface where the user can select the various controls. Basically you will have to iterate over all controls using the method described above. Each control class starts with a control of type V4L2_CTRL_TYPE_CTRL_CLASS. VIDIOC_QUERYCTRL will return the name of this control class which can be used as the title of a tab page within a control panel.
The flags field of struct v4l2_queryctrl also contains hints on the behavior of the control. See the vidioc_queryctrl documentation for more details.
Field Order
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
We have to distinguish between progressive and interlaced video. Progressive video transmits all lines of a video image sequentially. Interlaced video divides an image into two fields, containing only the odd and even lines of the image, respectively. Alternating the so called odd and even field are transmitted, and due to a small delay between fields a cathode ray TV displays the lines interleaved, yielding the original frame. This curious technique was invented because at refresh rates similar to film the image would fade out too quickly. Transmitting fields reduces the flicker without the necessity of doubling the frame rate and with it the bandwidth required for each channel.
It is important to understand a video camera does not expose one frame at a time, merely transmitting the frames separated into fields. The fields are in fact captured at two different instances in time. An object on screen may well move between one field and the next. For applications analysing motion it is of paramount importance to recognize which field of a frame is older, the temporal order.
When the driver provides or accepts images field by field rather than interleaved, it is also important applications understand how the fields combine to frames. We distinguish between top (aka odd) and bottom (aka even) fields, the spatial order: The first line of the top field is the first line of an interlaced frame, the first line of the bottom field is the second line of that frame.
However because fields were captured one after the other, arguing whether a frame commences with the top or bottom field is pointless. Any two successive top and bottom, or bottom and top fields yield a valid frame. Only when the source was progressive to begin with, e. g. when transferring film to video, two fields may come from the same frame, creating a natural order.
Counter to intuition the top field is not necessarily the older field. Whether the older field contains the top or bottom lines is a convention determined by the video standard. Hence the distinction between temporal and spatial order of fields. The diagrams below should make this clearer.
In V4L it is assumed that all video cameras transmit fields on the media bus in the same order they were captured, so if the top field was captured first (is the older field), the top field is also transmitted first on the bus.
All video capture and output devices must report the current field order. Some drivers may permit the selection of a different order, to this end applications initialize the field field of struct v4l2_pix_format before calling the VIDIOC_S_FMT ioctl. If this is not desired it should have the value V4L2_FIELD_ANY (0).
enum v4l2_field #
v4l2_field
|
|
0 |
Applications request this field order when any field format is acceptable. Drivers choose depending on hardware capabilities or e.g. the requested image size, and return the actual field order. Drivers must never return |
|
|
1 |
Images are in progressive (frame-based) format, not interlaced (field-based). |
|
|
2 |
Images consist of the top (aka odd) field only. |
|
|
3 |
Images consist of the bottom (aka even) field only. Applications may wish to prevent a device from capturing interlaced images because they will have "comb" or "feathering" artefacts around moving objects. |
|
|
4 |
Images contain both fields, interleaved line by line. The temporal order of the fields (whether the top or bottom field is older) depends on the current video standard. In M/NTSC the bottom field is the older field. In all other standards the top field is the older field. |
|
|
5 |
Images contain both fields, the top field lines are stored first in memory, immediately followed by the bottom field lines. Fields are always stored in temporal order, the older one first in memory. Image sizes refer to the frame, not fields. |
|
|
6 |
Images contain both fields, the bottom field lines are stored first in memory, immediately followed by the top field lines. Fields are always stored in temporal order, the older one first in memory. Image sizes refer to the frame, not fields. |
|
|
7 |
The two fields of a frame are passed in separate buffers, in temporal order, i. e. the older one first. To indicate the field parity (whether the current field is a top or bottom field) the driver or application, depending on data direction, must set struct |
|
|
8 |
Images contain both fields, interleaved line by line, top field first. The top field is the older field. |
|
|
9 |
Images contain both fields, interleaved line by line, top field first. The bottom field is the older field. |
Field Order, Top Field First Transmitted #
Field Order, Top Field First Transmitted
Field Order, Bottom Field First Transmitted #
Field Order, Bottom Field First Transmitted
Data Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Data Format Negotiation #
Different devices exchange different kinds of data with applications, for example video images, raw or sliced VBI data, RDS datagrams. Even within one kind many different formats are possible, in particular there is an abundance of image formats. Although drivers must provide a default and the selection persists across closing and reopening a device, applications should always negotiate a data format before engaging in data exchange. Negotiation means the application asks for a particular format and the driver selects and reports the best the hardware can do to satisfy the request. Of course applications can also just query the current selection.
A single mechanism exists to negotiate all data formats using the aggregate struct v4l2_format and the VIDIOC_G_FMT and VIDIOC_S_FMT ioctls. Additionally the VIDIOC_TRY_FMT ioctl can be used to examine what the hardware could do, without actually selecting a new data format. The data formats supported by the V4L2 API are covered in the respective device section in Interfaces. For a closer look at image formats see Image Formats.
The VIDIOC_S_FMT ioctl is a major turning-point in the initialization sequence. Prior to this point multiple panel applications can access the same device concurrently to select the current input, change controls or modify other properties. The first VIDIOC_S_FMT assigns a logical stream (video data, VBI data etc.) exclusively to one file descriptor.
Exclusive means no other application, more precisely no other file descriptor, can grab this stream or change device properties inconsistent with the negotiated parameters. A video standard change for example, when the new standard uses a different number of scan lines, can invalidate the selected image format. Therefore only the file descriptor owning the stream can make invalidating changes. Accordingly multiple file descriptors which grabbed different logical streams prevent each other from interfering with their settings. When for example video overlay is about to start or already in progress, simultaneous video capturing may be restricted to the same cropping and image size.
When applications omit the VIDIOC_S_FMT ioctl its locking side effects are implied by the next step, the selection of an I/O method with the vidioc_reqbufs ioctl or implicit with the first read() or write() call.
Generally only one logical stream can be assigned to a file descriptor, the exception being drivers permitting simultaneous video capturing and overlay using the same file descriptor for compatibility with V4L and earlier versions of V4L2. Switching the logical stream or returning into "panel mode" is possible by closing and reopening the device. Drivers may support a switch using VIDIOC_S_FMT.
All drivers exchanging data with applications must support the VIDIOC_G_FMT and VIDIOC_S_FMT ioctl. Implementation of the VIDIOC_TRY_FMT is highly recommended but optional.
Image Format Enumeration #
Apart of the generic format negotiation functions a special ioctl to enumerate all image formats supported by video capture, overlay or output devices is available. 1
The ioctl VIDIOC_ENUM_FMT ioctl must be supported by all drivers exchanging image data with applications.
[1] Enumerating formats an application has no a-priori knowledge of (otherwise it could explicitly ask for them and need not enumerate) seems useless, but there are applications serving as proxy between drivers and the actual video applications for which this is useful.
Guidelines for Video4Linux pixel format 4CCs
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Guidelines for Video4Linux 4CC codes defined using v4l2_fourcc() are specified in this document. First of the characters defines the nature of the pixel format, compression and colour space. The interpretation of the other three characters depends on the first one.
Existing 4CCs may not obey these guidelines.
Raw bayer #
The following first characters are used by raw bayer formats:
-
B: raw bayer, uncompressed
-
b: raw bayer, DPCM compressed
-
a: A-law compressed
-
u: u-law compressed
2nd character: pixel order
-
B: BGGR
-
G: GBRG
-
g: GRBG
-
R: RGGB
3rd character: uncompressed bits-per-pixel 0--9, A--
4th character: compressed bits-per-pixel 0--9, A--
V4L2 close()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-close - Close a V4L2 device
Synopsis #
int Arguments #
-
fdFile descriptor returned by
open().
Description #
Closes the device. Any I/O in progress is terminated and resources associated with the file descriptor are freed. However data format parameters, current input or output, control values or other properties remain unchanged.
Return Value #
The function returns 0 on success, -1 on failure and the errno is set appropriately. Possible error codes:
-
EBADF
fdis not a valid open file descriptor.
V4L2 ioctl()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-ioctl - Program a V4L2 device
Synopsis #
int ioctl(int fd, int request, void *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
requestV4L2 ioctl request code as defined in the
videodev2.hheader file, for example VIDIOC_QUERYCAP. -
argpPointer to a function parameter, usually a structure.
Description #
The ioctl() function is used to program V4L2 devices. The argument fd must be an open file descriptor. An ioctl request has encoded in it whether the argument is an input, output or read/write parameter, and the size of the argument argp in bytes. Macros and defines specifying V4L2 ioctl requests are located in the videodev2.h header file. Applications should use their own copy, not include the version in the kernel sources on the system they compile on. All V4L2 ioctl requests, their respective function and parameters are specified in Function Reference.
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.
When an ioctl that takes an output or read/write parameter fails, the parameter remains unmodified.
V4L2 mmap()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-mmap - Map device memory into application address space
Synopsis #
void *Arguments #
-
startMap the buffer to this address in the application's address space. When the
MAP_FIXEDflag is specified,startmust be a multiple of the pagesize and mmap will fail when the specified address cannot be used. Use of this option is discouraged; applications should just specify aNULLpointer here. -
lengthLength of the memory area to map. This must be the same value as returned by the driver in the struct
v4l2_bufferlengthfield for the single-planar API, and the same value as returned by the driver in the structv4l2_planelengthfield for the multi-planar API. -
protThe
protargument describes the desired memory protection. Regardless of the device type and the direction of data exchange it should be set toPROT_READ|PROT_WRITE, permitting read and write access to image buffers. Drivers should support at least this combination of flags. -
flagsThe
flagsparameter specifies the type of the mapped object, mapping options and whether modifications made to the mapped copy of the page are private to the process or are to be shared with other references.MAP_FIXEDrequests that the driver selects no other address than the one specified. If the specified address cannot be used,mmap()will fail. IfMAP_FIXEDis specified,startmust be a multiple of the pagesize. Use of this option is discouraged.One of the
MAP_SHAREDorMAP_PRIVATEflags must be set.MAP_SHAREDallows applications to share the mapped memory with other (e. g. child-) processes. -
fdFile descriptor returned by
open(). -
offsetOffset of the buffer in device memory. This must be the same value as returned by the driver in the struct
v4l2_buffermunionoffsetfield for the single-planar API, and the same value as returned by the driver in the structv4l2_planemunionmem_offsetfield for the multi-planar API.
Description #
The mmap() function asks to map length bytes starting at offset in the memory of the device specified by fd into the application address space, preferably at address start. This latter address is a hint only, and is usually specified as 0.
Suitable length and offset parameters are queried with the ioctl VIDIOC_QUERYBUF ioctl. Buffers must be allocated with the vidioc_reqbufs ioctl before they can be queried.
To unmap buffers the munmap() function is used.
Return Value #
On success mmap() returns a pointer to the mapped buffer. On error MAP_FAILED (-1) is returned, and the errno variable is set appropriately. Possible error codes are:
-
EBADF
fdis not a valid file descriptor. -
EACCES
fdis not open for reading and writing. -
EINVAL
The
startorlengthoroffsetare not suitable. (E. g. they are too large, or not aligned on aPAGESIZEboundary.)The
flagsorprotvalue is not supported.No buffers have been allocated with the vidioc_reqbufs ioctl.
-
ENOMEM
Not enough physical or virtual memory was available to complete the request.
V4L2 munmap()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-munmap - Unmap device memory
Synopsis #
int Arguments #
-
startAddress of the mapped buffer as returned by the
mmap()function. -
lengthLength of the mapped buffer. This must be the same value as given to
mmap()and returned by the driver in the structv4l2_bufferlengthfield for the single-planar API and in the structv4l2_planelengthfield for the multi-planar API.
Description #
Unmaps a previously with the mmap() function mapped buffer and frees it, if possible.
Return Value #
On success munmap() returns 0, on failure -1 and the errno variable is set appropriately:
-
EINVAL
The
startorlengthis incorrect, or no buffers have been mapped yet.
V4L2 open()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-open - Open a V4L2 device
Synopsis #
int Arguments #
-
device_nameDevice to be opened.
-
flagsOpen flags. Access mode must be
O_RDWR. This is just a technicality, input devices still support only reading and output devices only writing.When the
O_NONBLOCKflag is given, theread()function and the VIDIOC_DQBUF ioctl will return theEAGAINerror code when no data is available or no buffer is in the driver outgoing queue, otherwise these functions block until data becomes available. All V4L2 drivers exchanging data with applications must support theO_NONBLOCKflag.Other flags have no effect.
Description #
To open a V4L2 device applications call open() with the desired device name. This function has no side effects; all data format parameters, current input or output, control values or other properties remain unchanged. At the first open() call after loading the driver they will be reset to default values, drivers are never in an undefined state.
Return Value #
On success open() returns the new file descriptor. On error -1 is returned, and the errno variable is set appropriately. Possible error codes are:
-
EACCES
The caller has no permission to access the device.
-
EBUSY
The driver does not support multiple opens and the device is already in use.
-
ENODEV
Device not found or was removed.
-
ENOMEM
Not enough kernel memory was available to complete the request.
-
EMFILE
The process already has the maximum number of files open.
-
ENFILE
The limit on the total number of files open on the system has been reached.
V4L2 poll()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-poll - Wait for some event on a file descriptor
Synopsis #
int Arguments #
Description #
With the poll() function applications can suspend execution until the driver has captured data or is ready to accept data for output.
When streaming I/O has been negotiated this function waits until a buffer has been filled by the capture device and can be dequeued with the VIDIOC_DQBUF ioctl. For output devices this function waits until the device is ready to accept a new buffer to be queued up with the VIDIOC_QBUF ioctl for display. When buffers are already in the outgoing queue of the driver (capture) or the incoming queue isn't full (display) the function returns immediately.
On success poll() returns the number of file descriptors that have been selected (that is, file descriptors for which the revents field of the respective struct pollfd structure is non-zero). Capture devices set the POLLIN and POLLRDNORM flags in the revents field, output devices the POLLOUT and POLLWRNORM flags. When the function timed out it returns a value of zero, on failure it returns -1 and the errno variable is set appropriately. When the application did not call VIDIOC_STREAMON the poll() function succeeds, but sets the POLLERR flag in the revents field. When the application has called VIDIOC_STREAMON for a capture device but hasn't yet called VIDIOC_QBUF, the poll() function succeeds and sets the POLLERR flag in the revents field. For output devices this same situation will cause poll() to succeed as well, but it sets the POLLOUT and POLLWRNORM flags in the revents field.
If an event occurred (see ioctl VIDIOC_DQEVENT) then POLLPRI will be set in the revents field and poll() will return.
When use of the read() function has been negotiated and the driver does not capture yet, the poll() function starts capturing. When that fails it returns a POLLERR as above. Otherwise it waits until data has been captured and can be read. When the driver captures continuously (as opposed to, for example, still images) the function may return immediately.
When use of the write() function has been negotiated and the driver does not stream yet, the poll() function starts streaming. When that fails it returns a POLLERR as above. Otherwise it waits until the driver is ready for a non-blocking write() call.
If the caller is only interested in events (just POLLPRI is set in the events field), then poll() will not start streaming if the driver does not stream yet. This makes it possible to just poll for events and not for buffers.
All drivers implementing the read() or write() function or streaming I/O must also support the poll() function.
For more details see the poll() manual page.
Return Value #
On success, poll() returns the number structures which have non-zero revents fields, or zero if the call timed out. On error -1 is returned, and the errno variable is set appropriately:
-
EBADF
One or more of the
ufdsmembers specify an invalid file descriptor. -
EBUSY
The driver does not support multiple read or write streams and the device is already in use.
-
EFAULT
ufdsreferences an inaccessible memory area. -
EINTR
The call was interrupted by a signal.
-
EINVAL
The
nfdsvalue exceeds theRLIMIT_NOFILEvalue. Usegetrlimit()to obtain this value.
V4L2 read()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-read - Read from a V4L2 device
Synopsis #
ssize_t Arguments #
-
fdFile descriptor returned by
open(). -
bufBuffer to be filled
-
countMax number of bytes to read
Description #
read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf. The layout of the data in the buffer is discussed in the respective device interface section, see ##. If count is zero, read() returns zero and has no other results. If count is greater than SSIZE_MAX, the result is unspecified. Regardless of the count value each read() call will provide at most one frame (two fields) worth of data.
By default read() blocks until data becomes available. When the O_NONBLOCK flag was given to the open() function it returns immediately with an EAGAIN error code when no data is available. The select() or poll() functions can always be used to suspend execution until data becomes available. All drivers supporting the read() function must also support select() and poll().
Drivers can implement read functionality in different ways, using a single or multiple buffers and discarding the oldest or newest frames once the internal buffers are filled.
read() never returns a "snapshot" of a buffer being filled. Using a single buffer the driver will stop capturing when the application starts reading the buffer until the read is finished. Thus only the period of the vertical blanking interval is available for reading, or the capture rate must fall below the nominal frame rate of the video standard.
The behavior of read() when called during the active picture period or the vertical blanking separating the top and bottom field depends on the discarding policy. A driver discarding the oldest frames keeps capturing into an internal buffer, continuously overwriting the previously, not read frame, and returns the frame being received at the time of the read() call as soon as it is complete.
A driver discarding the newest frames stops capturing until the next read() call. The frame being received at read() time is discarded, returning the following frame instead. Again this implies a reduction of the capture rate to one half or less of the nominal frame rate. An example of this model is the video read mode of the bttv driver, initiating a DMA to user memory when read() is called and returning when the DMA finished.
In the multiple buffer model drivers maintain a ring of internal buffers, automatically advancing to the next free buffer. This allows continuous capturing when the application can empty the buffers fast enough. Again, the behavior when the driver runs out of free buffers depends on the discarding policy.
Applications can get and set the number of buffers used internally by the driver with the VIDIOC_G_PARM and VIDIOC_S_PARM ioctls. They are optional, however. The discarding policy is not reported and cannot be changed. For minimum requirements see Interfaces.
Return Value #
On success, the number of bytes read is returned. It is not an error if this number is smaller than the number of bytes requested, or the amount of data required for one frame. This may happen for example because read() was interrupted by a signal. On error, -1 is returned, and the errno variable is set appropriately. In this case the next read will start at the beginning of a new frame. Possible error codes are:
-
EAGAIN
Non-blocking I/O has been selected using O_NONBLOCK and no data was immediately available for reading.
-
EBADF
fdis not a valid file descriptor or is not open for reading, or the process already has the maximum number of files open. -
EBUSY
The driver does not support multiple read streams and the device is already in use.
-
EFAULT
bufreferences an inaccessible memory area. -
EINTR
The call was interrupted by a signal before any data was read.
-
EIO
I/O error. This indicates some hardware problem or a failure to communicate with a remote device (USB camera etc.).
-
EINVAL
The
read()function is not supported by this driver, not on this device, or generally not on this type of device.
V4L2 select()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-select - Synchronous I/O multiplexing
Synopsis #
int Arguments #
-
nfdsThe highest-numbered file descriptor in any of the three sets, plus 1.
-
readfdsFile descriptions to be watched if a read() call won't block.
-
writefdsFile descriptions to be watched if a write() won't block.
-
exceptfdsFile descriptions to be watched for V4L2 events.
-
timeoutMaximum time to wait.
Description #
With the select() function applications can suspend execution until the driver has captured data or is ready to accept data for output.
When streaming I/O has been negotiated this function waits until a buffer has been filled or displayed and can be dequeued with the VIDIOC_DQBUF ioctl. When buffers are already in the outgoing queue of the driver the function returns immediately.
On success select() returns the total number of bits set in fd_set. When the function timed out it returns a value of zero. On failure it returns -1 and the errno variable is set appropriately. When the application did not call ioctl VIDIOC_QBUF, VIDIOC_DQBUF or ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF yet the select() function succeeds, setting the bit of the file descriptor in readfds or writefds, but subsequent VIDIOC_DQBUF calls will fail. 1
When use of the read() function has been negotiated and the driver does not capture yet, the select() function starts capturing. When that fails, select() returns successful and a subsequent read() call, which also attempts to start capturing, will return an appropriate error code. When the driver captures continuously (as opposed to, for example, still images) and data is already available the select() function returns immediately.
When use of the write() function has been negotiated the select() function just waits until the driver is ready for a non-blocking write() call.
All drivers implementing the read() or write() function or streaming I/O must also support the select() function.
For more details see the select() manual page.
Return Value #
On success, select() returns the number of descriptors contained in the three returned descriptor sets, which will be zero if the timeout expired. On error -1 is returned, and the errno variable is set appropriately; the sets and timeout are undefined. Possible error codes are:
-
EBADF
One or more of the file descriptor sets specified a file descriptor that is not open.
-
EBUSY
The driver does not support multiple read or write streams and the device is already in use.
-
EFAULT
The
readfds,writefds,exceptfdsortimeoutpointer references an inaccessible memory area. -
EINTR
The call was interrupted by a signal.
-
EINVAL
The
nfdsargument is less than zero or greater thanFD_SETSIZE.
[1] The Linux kernel implements select() like the poll() function, but select() cannot return a POLLERR.
V4L2 write()
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
v4l2-write - Write to a V4L2 device
Synopsis #
ssize_t Arguments #
-
fdFile descriptor returned by
open(). -
bufBuffer with data to be written
-
countNumber of bytes at the buffer
Description #
write() writes up to count bytes to the device referenced by the file descriptor fd from the buffer starting at buf. When the hardware outputs are not active yet, this function enables them. When count is zero, write() returns 0 without any other effect.
When the application does not provide more data in time, the previous video frame, raw VBI image, sliced VPS or WSS data is displayed again. Sliced Teletext or Closed Caption data is not repeated, the driver inserts a blank line instead.
Return Value #
On success, the number of bytes written are returned. Zero indicates nothing was written. On error, -1 is returned, and the errno variable is set appropriately. In this case the next write will start at the beginning of a new frame. Possible error codes are:
-
EAGAIN
Non-blocking I/O has been selected using the O_NONBLOCK flag and no buffer space was available to write the data immediately.
-
EBADF
fdis not a valid file descriptor or is not open for writing. -
EBUSY
The driver does not support multiple write streams and the device is already in use.
-
EFAULT
bufreferences an inaccessible memory area. -
EINTR
The call was interrupted by a signal before any data was written.
-
EIO
I/O error. This indicates some hardware problem.
-
EINVAL
The
write()function is not supported by this driver, not on this device, or generally not on this type of device.
Changes of the V4L2 API
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Soon after the V4L API was added to the kernel it was criticised as too inflexible. In August 1998 Bill Dirks proposed a number of improvements and began to work on documentation, example drivers and applications. With the help of other volunteers this eventually became the V4L2 API, not just an extension but a replacement for the V4L API. However it took another four years and two stable kernel releases until the new API was finally accepted for inclusion into the kernel in its present form.
Early Versions #
1998-08-20: First version.
1998-08-27: The select() function was introduced.
1998-09-10: New video standard interface.
1998-09-18: The VIDIOC_NONCAP ioctl was replaced by the otherwise meaningless O_TRUNC open() flag, and the aliases O_NONCAP and O_NOIO were defined. Applications can set this flag if they intend to access controls only, as opposed to capture applications which need exclusive access. The VIDEO_STD_XXX identifiers are now ordinals instead of flags, and the video_std_construct() helper function takes id and transmission arguments.
1998-09-28: Revamped video standard. Made video controls individually enumerable.
1998-10-02: The id field was removed from struct video_standard and the color subcarrier fields were renamed. The vidioc_querystd ioctl was renamed to ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD, VIDIOC_G_INPUT to vidioc_enuminput. A first draft of the Codec API was released.
1998-11-08: Many minor changes. Most symbols have been renamed. Some material changes to struct v4l2_capability.
1998-11-12: The read/write direction of some ioctls was misdefined.
1998-11-14: V4L2_PIX_FMT_RGB24 changed to V4L2_PIX_FMT_BGR24, and V4L2_PIX_FMT_RGB32 changed to V4L2_PIX_FMT_BGR32. Audio controls are now accessible with the VIDIOC_G_CTRL and VIDIOC_S_CTRL ioctls under names starting with V4L2_CID_AUDIO. The V4L2_MAJOR define was removed from videodev.h since it was only used once in the videodev kernel module. The YUV422 and YUV411 planar image formats were added.
1998-11-28: A few ioctl symbols changed. Interfaces for codecs and video output devices were added.
1999-01-14: A raw VBI capture interface was added.
1999-01-19: The VIDIOC_NEXTBUF ioctl was removed.
V4L2 Version 0.16 1999-01-31 #
1999-01-27: There is now one QBUF ioctl, VIDIOC_QWBUF and VIDIOC_QRBUF are gone. VIDIOC_QBUF takes a v4l2_buffer as a parameter. Added digital zoom (cropping) controls.
V4L2 Version 0.18 1999-03-16 #
Added a v4l to V4L2 ioctl compatibility layer to videodev.c. Driver writers, this changes how you implement your ioctl handler. See the Driver Writer's Guide. Added some more control id codes.
V4L2 Version 0.19 1999-06-05 #
1999-03-18: Fill in the category and catname fields of v4l2_queryctrl objects before passing them to the driver. Required a minor change to the VIDIOC_QUERYCTRL handlers in the sample drivers.
1999-03-31: Better compatibility for v4l memory capture ioctls. Requires changes to drivers to fully support new compatibility features, see Driver Writer's Guide and v4l2cap.c. Added new control IDs: V4L2_CID_HFLIP, _VFLIP. Changed V4L2_PIX_FMT_YUV422P to _YUV422P, and _YUV411P to _YUV411P.
1999-04-04: Added a few more control IDs.
1999-04-07: Added the button control type.
1999-05-02: Fixed a typo in videodev.h, and added the V4L2_CTRL_FLAG_GRAYED (later V4L2_CTRL_FLAG_GRABBED) flag.
1999-05-20: Definition of VIDIOC_G_CTRL was wrong causing a malfunction of this ioctl.
1999-06-05: Changed the value of V4L2_CID_WHITENESS.
V4L2 Version 0.20 (1999-09-10) #
Version 0.20 introduced a number of changes which were not backward compatible with 0.19 and earlier versions. Purpose of these changes was to simplify the API, while making it more extensible and following common Linux driver API conventions.
-
Some typos in
V4L2_FMT_FLAGsymbols were fixed. struct v4l2_clip was changed for compatibility with v4l. (1999-08-30) -
V4L2_TUNER_SUB_LANG1was added. (1999-09-05) -
All ioctl() commands that used an integer argument now take a pointer to an integer. Where it makes sense, ioctls will return the actual new value in the integer pointed to by the argument, a common convention in the V4L2 API. The affected ioctls are: VIDIOC_PREVIEW, VIDIOC_STREAMON, VIDIOC_STREAMOFF, VIDIOC_S_FREQ, VIDIOC_S_INPUT, VIDIOC_S_OUTPUT, VIDIOC_S_EFFECT. For example
err = ;becomes
int a = V4L2_XXX; err = ; -
All the different get- and set-format commands were swept into one VIDIOC_G_FMT and VIDIOC_S_FMT ioctl taking a union and a type field selecting the union member as parameter. Purpose is to simplify the API by eliminating several ioctls and to allow new and driver private data streams without adding new ioctls.
This change obsoletes the following ioctls:
VIDIOC_S_INFMT,VIDIOC_G_INFMT,VIDIOC_S_OUTFMT,VIDIOC_G_OUTFMT,VIDIOC_S_VBIFMTandVIDIOC_G_VBIFMT. The image format struct v4l2_format was renamed to struct v4l2_pix_format, while struct v4l2_format is now the enveloping structure for all format negotiations. -
Similar to the changes above, the
VIDIOC_G_PARMandVIDIOC_S_PARMioctls were merged withVIDIOC_G_OUTPARMandVIDIOC_S_OUTPARM. Atypefield in the new struct v4l2_streamparm selects the respective union member.This change obsoletes the
VIDIOC_G_OUTPARMandVIDIOC_S_OUTPARMioctls. -
Control enumeration was simplified, and two new control flags were introduced and one dropped. The
catnamefield was replaced by agroupfield.Drivers can now flag unsupported and temporarily unavailable controls with
V4L2_CTRL_FLAG_DISABLEDandV4L2_CTRL_FLAG_GRABBEDrespectively. Thegroupname indicates a possibly narrower classification than thecategory. In other words, there may be multiple groups within a category. Controls within a group would typically be drawn within a group box. Controls in different categories might have a greater separation, or may even appear in separate windows. -
The struct v4l2_buffer
timestampwas changed to a 64 bit integer, containing the sampling or output time of the frame in nanoseconds. Additionally timestamps will be in absolute system time, not starting from zero at the beginning of a stream. The data type name for timestamps is stamp_t, defined as a signed 64-bit integer. Output devices should not send a buffer out until the time in the timestamp field has arrived. I would like to follow SGI's lead, and adopt a multimedia timestamping system like their UST (Unadjusted System Time). See http://web.archive.org/web/*/http://reality.sgi.com /cpirazzi_engr/lg/time/intro.html. UST uses timestamps that are 64-bit signed integers (not struct timeval's) and given in nanosecond units. The UST clock starts at zero when the system is booted and runs continuously and uniformly. It takes a little over 292 years for UST to overflow. There is no way to set the UST clock. The regular Linux time-of-day clock can be changed periodically, which would cause errors if it were being used for timestamping a multimedia stream. A real UST style clock will require some support in the kernel that is not there yet. But in anticipation, I will change the timestamp field to a 64-bit integer, and I will change the v4l2_masterclock_gettime() function (used only by drivers) to return a 64-bit integer. -
A
sequencefield was added to struct v4l2_buffer. Thesequencefield counts captured frames, it is ignored by output devices. When a capture driver drops a frame, the sequence number of that frame is skipped.
V4L2 Version 0.20 incremental changes #
1999-12-23: In struct v4l2_vbi_format the reserved1 field became offset. Previously drivers were required to clear the reserved1 field.
2000-01-13: The V4L2_FMT_FLAG_NOT_INTERLACED flag was added.
2000-07-31: The linux/poll.h header is now included by videodev.h for compatibility with the original videodev.h file.
2000-11-20: V4L2_TYPE_VBI_OUTPUT and V4L2_PIX_FMT_Y41P were added.
2000-11-25: V4L2_TYPE_VBI_INPUT was added.
2000-12-04: A couple typos in symbol names were fixed.
2001-01-18: To avoid namespace conflicts the fourcc macro defined in the videodev.h header file was renamed to v4l2_fourcc.
2001-01-25: A possible driver-level compatibility problem between the videodev.h file in Linux 2.4.0 and the videodev.h file included in the videodevX patch was fixed. Users of an earlier version of videodevX on Linux 2.4.0 should recompile their V4L and V4L2 drivers.
2001-01-26: A possible kernel-level incompatibility between the videodev.h file in the videodevX patch and the videodev.h file in Linux 2.2.x with devfs patches applied was fixed.
2001-03-02: Certain V4L ioctls which pass data in both direction although they are defined with read-only parameter, did not work correctly through the backward compatibility layer. [Solution?]
2001-04-13: Big endian 16-bit RGB formats were added.
2001-09-17: New YUV formats and the VIDIOC_G_FREQUENCY and VIDIOC_S_FREQUENCY ioctls were added. (The old VIDIOC_G_FREQ and VIDIOC_S_FREQ ioctls did not take multiple tuners into account.)
2000-09-18: V4L2_BUF_TYPE_VBI was added. This may break compatibility as the VIDIOC_G_FMT and VIDIOC_S_FMT ioctls may fail now if the struct v4l2_fmt type field does not contain V4L2_BUF_TYPE_VBI. In the documentation of the struct v4l2_vbi_format`, the offset field the ambiguous phrase "rising edge" was changed to "leading edge".
V4L2 Version 0.20 2000-11-23 #
A number of changes were made to the raw VBI interface.
-
Figures clarifying the line numbering scheme were added to the V4L2 API specification. The
start[0] andstart[1] fields no longer count line numbers beginning at zero. Rationale: a) The previous definition was unclear. b) Thestart[] values are ordinal numbers. c) There is no point in inventing a new line numbering scheme. We now use line number as defined by ITU-R, period. Compatibility: Add one to the start values. Applications depending on the previous semantics may not function correctly. -
The restriction "count[0] > 0 and count[1] > 0" has been relaxed to "(count[0] + count[1]) > 0". Rationale: Drivers may allocate resources at scan line granularity and some data services are transmitted only on the first field. The comment that both
countvalues will usually be equal is misleading and pointless and has been removed. This change breaks compatibility with earlier versions: Drivers may returnEINVAL, applications may not function correctly. -
Drivers are again permitted to return negative (unknown) start values as proposed earlier. Why this feature was dropped is unclear. This change may break compatibility with applications depending on the start values being positive. The use of
EBUSYandEINVALerror codes with the VIDIOC_S_FMT ioctl was clarified. TheEBUSYerror code was finally documented, and thereserved2field which was previously mentioned only in thevideodev.hheader file. -
New buffer types
V4L2_TYPE_VBI_INPUTandV4L2_TYPE_VBI_OUTPUTwere added. The former is an alias for the oldV4L2_TYPE_VBI, the latter was missing in thevideodev.hfile.
V4L2 Version 0.20 2002-07-25 #
Added sliced VBI interface proposal.
V4L2 in Linux 2.5.46, 2002-10 #
Around October-November 2002, prior to an announced feature freeze of Linux 2.5, the API was revised, drawing from experience with V4L2 0.20. This unnamed version was finally merged into Linux 2.5.46.
-
As specified in related, drivers must make related device functions available under all minor device numbers.
-
The
open()function requires access modeO_RDWRregardless of the device type. All V4L2 drivers exchanging data with applications must support theO_NONBLOCKflag. TheO_NOIOflag, a V4L2 symbol which aliased the meaninglessO_TRUNCto indicate accesses without data exchange (panel applications) was dropped. Drivers must stay in "panel mode" until the application attempts to initiate a data exchange, see open. -
The struct v4l2_capability changed dramatically. Note that also the size of the structure changed, which is encoded in the ioctl request code, thus older V4L2 devices will respond with an
EINVALerror code to the new vidioc_querycap ioctl.There are new fields to identify the driver, a new RDS device function
V4L2_CAP_RDS_CAPTURE, theV4L2_CAP_AUDIOflag indicates if the device has any audio connectors, another I/O capability V4L2_CAP_ASYNCIO can be flagged. In response to these changes thetypefield became a bit set and was merged into theflagsfield.V4L2_FLAG_TUNERwas renamed toV4L2_CAP_TUNER,V4L2_CAP_VIDEO_OVERLAYreplacedV4L2_FLAG_PREVIEWandV4L2_CAP_VBI_CAPTUREandV4L2_CAP_VBI_OUTPUTreplacedV4L2_FLAG_DATA_SERVICE.V4L2_FLAG_READandV4L2_FLAG_WRITEwere merged intoV4L2_CAP_READWRITE.The redundant fields
inputs,outputsandaudioswere removed. These properties can be determined as described in video and audio.The somewhat volatile and therefore barely useful fields
maxwidth,maxheight,minwidth,minheight,maxframeratewere removed. This information is available as described in format and standard.V4L2_FLAG_SELECTwas removed. We believe the select() function is important enough to require support of it in all V4L2 drivers exchanging data with applications. The redundantV4L2_FLAG_MONOCHROMEflag was removed, this information is available as described in format. -
In struct v4l2_input the
assoc_audiofield and thecapabilityfield and its only flagV4L2_INPUT_CAP_AUDIOwas replaced by the newaudiosetfield. Instead of linking one video input to one audio input this field reports all audio inputs this video input combines with.New fields are
tuner(reversing the former link from tuners to video inputs),stdandstatus.Accordingly struct v4l2_output lost its
capabilityandassoc_audiofields.audioset,modulatorandstdwhere added instead. -
The struct v4l2_audio field
audiowas renamed toindex, for consistency with other structures. A new capability flagV4L2_AUDCAP_STEREOwas added to indicated if the audio input in question supports stereo sound.V4L2_AUDCAP_EFFECTSand the correspondingV4L2_AUDMODEflags where removed. This can be easily implemented using controls. (However the same applies to AVL which is still there.)Again for consistency the struct v4l2_audioout field
audiowas renamed toindex. -
The struct v4l2_tuner
inputfield was replaced by anindexfield, permitting devices with multiple tuners. The link between video inputs and tuners is now reversed, inputs point to their tuner. Thestdsubstructure became a simple set (more about this below) and moved into struct v4l2_input. Atypefield was added.Accordingly in struct v4l2_modulator the
outputwas replaced by anindexfield.In struct v4l2_frequency the
portfield was replaced by atunerfield containing the respective tuner or modulator index number. A tunertypefield was added and thereservedfield became larger for future extensions (satellite tuners in particular). -
The idea of completely transparent video standards was dropped. Experience showed that applications must be able to work with video standards beyond presenting the user a menu. Instead of enumerating supported standards with an ioctl applications can now refer to standards by v4l2_std_id and symbols defined in the
videodev2.hheader file. For details see standard. The VIDIOC_G_STD and VIDIOC_S_STD now take a pointer to this type as argument. vidioc_querystd was added to autodetect the received standard, if the hardware has this capability. In struct v4l2_standard anindexfield was added for ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD. A v4l2_std_id field namedidwas added as machine readable identifier, also replacing thetransmissionfield. The misleadingframeratefield was renamed toframeperiod. The now obsoletecolorstandardinformation, originally needed to distguish between variations of standards, were removed.Struct
v4l2_enumstdceased to be. ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD now takes a pointer to a struct v4l2_standard directly. The information which standards are supported by a particular video input or output moved into struct v4l2_input and struct v4l2_output fields namedstd, respectively. -
The struct v4l2_queryctrl fields
categoryandgroupdid not catch on and/or were not implemented as expected and therefore removed. -
The VIDIOC_TRY_FMT ioctl was added to negotiate data formats as with VIDIOC_S_FMT, but without the overhead of programming the hardware and regardless of I/O in progress.
In struct v4l2_format the
fmtunion was extended to contain struct v4l2_window. All image format negotiations are now possible withVIDIOC_G_FMT,VIDIOC_S_FMTandVIDIOC_TRY_FMT; ioctl. TheVIDIOC_G_WINandVIDIOC_S_WINioctls to prepare for a video overlay were removed. Thetypefield changed to type enum v4l2_buf_type and the buffer type names changed as follows.Old defines
enum v4l2_buf_type
V4L2_BUF_TYPE_CAPTUREV4L2_BUF_TYPE_VIDEO_CAPTUREV4L2_BUF_TYPE_CODECINOmitted for now
V4L2_BUF_TYPE_CODECOUTOmitted for now
V4L2_BUF_TYPE_EFFECTSINOmitted for now
V4L2_BUF_TYPE_EFFECTSIN2Omitted for now
V4L2_BUF_TYPE_EFFECTSOUTOmitted for now
V4L2_BUF_TYPE_VIDEOOUTV4L2_BUF_TYPE_VIDEO_OUTPUT-V4L2_BUF_TYPE_VIDEO_OVERLAY-V4L2_BUF_TYPE_VBI_CAPTURE-V4L2_BUF_TYPE_VBI_OUTPUT-V4L2_BUF_TYPE_SLICED_VBI_CAPTURE-V4L2_BUF_TYPE_SLICED_VBI_OUTPUTV4L2_BUF_TYPE_PRIVATE_BASEV4L2_BUF_TYPE_PRIVATE(but this is deprecated) -
In struct v4l2_fmtdesc a enum v4l2_buf_type field named
typewas added as in struct v4l2_format. TheVIDIOC_ENUM_FBUFFMTioctl is no longer needed and was removed. These calls can be replaced by vidioc_enum_fmt with typeV4L2_BUF_TYPE_VIDEO_OVERLAY. -
In struct v4l2_pix_format the
depthfield was removed, assuming applications which recognize the format by its four-character-code already know the color depth, and others do not care about it. The same rationale lead to the removal of theV4L2_FMT_FLAG_COMPRESSEDflag. TheV4L2_FMT_FLAG_SWCONVECOMPRESSEDflag was removed because drivers are not supposed to convert images in kernel space. A user library of conversion functions should be provided instead. TheV4L2_FMT_FLAG_BYTESPERLINEflag was redundant. Applications can set thebytesperlinefield to zero to get a reasonable default. Since the remaining flags were replaced as well, theflagsfield itself was removed.The interlace flags were replaced by a enum v4l2_field value in a newly added
fieldfield.Old flag
enum v4l2_field
V4L2_FMT_FLAG_NOT_INTERLACED?
V4L2_FMT_FLAG_INTERLACED=V4L2_FMT_FLAG_COMBINEDV4L2_FIELD_INTERLACEDV4L2_FMT_FLAG_TOPFIELD=V4L2_FMT_FLAG_ODDFIELDV4L2_FIELD_TOPV4L2_FMT_FLAG_BOTFIELD=V4L2_FMT_FLAG_EVENFIELDV4L2_FIELD_BOTTOM-V4L2_FIELD_SEQ_TB-V4L2_FIELD_SEQ_BT-V4L2_FIELD_ALTERNATEThe color space flags were replaced by a enum v4l2_colorspace value in a newly added
colorspacefield, where one ofV4L2_COLORSPACE_SMPTE170M,V4L2_COLORSPACE_BT878,V4L2_COLORSPACE_470_SYSTEM_MorV4L2_COLORSPACE_470_SYSTEM_BGreplacesV4L2_FMT_CS_601YUV. -
In struct v4l2_requestbuffers the
typefield was properly defined as enum v4l2_buf_type. Buffer types changed as mentioned above. A newmemoryfield of type enum v4l2_memory was added to distinguish between I/O methods using buffers allocated by the driver or the application. See io for details. -
In struct v4l2_buffer the
typefield was properly defined as enum v4l2_buf_type. Buffer types changed as mentioned above. Afieldfield of type enum v4l2_field was added to indicate if a buffer contains a top or bottom field. The old field flags were removed. Since no unadjusted system time clock was added to the kernel as planned, thetimestampfield changed back from type stamp_t, an unsigned 64 bit integer expressing the sample time in nanoseconds, to struct timeval. With the addition of a second memory mapping method theoffsetfield moved into unionm, and a newmemoryfield of type enum v4l2_memory was added to distinguish between I/O methods. See io for details.The
V4L2_BUF_REQ_CONTIGflag was used by the V4L compatibility layer, after changes to this code it was no longer needed. TheV4L2_BUF_ATTR_DEVICEMEMflag would indicate if the buffer was indeed allocated in device memory rather than DMA-able system memory. It was barely useful and so was removed. -
In struct v4l2_framebuffer the
base[3]array anticipating double- and triple-buffering in off-screen video memory, however without defining a synchronization mechanism, was replaced by a single pointer. TheV4L2_FBUF_CAP_SCALEUPandV4L2_FBUF_CAP_SCALEDOWNflags were removed. Applications can determine this capability more accurately using the new cropping and scaling interface. TheV4L2_FBUF_CAP_CLIPPINGflag was replaced byV4L2_FBUF_CAP_LIST_CLIPPINGandV4L2_FBUF_CAP_BITMAP_CLIPPING. -
In struct v4l2_clip the
x,y,widthandheightfield moved into acsubstructure of type struct v4l2_rect. Thexandyfields were renamed toleftandtop, i. e. offsets to a context dependent origin. -
In struct v4l2_window the
x,y,widthandheightfield moved into awsubstructure as above. Afieldfield of type enum v4l2_field was added to distinguish between field and frame (interlaced) overlay. -
The digital zoom interface, including struct
v4l2_zoomcap, structv4l2_zoom,V4L2_ZOOM_NONCAPandV4L2_ZOOM_WHILESTREAMINGwas replaced by a new cropping and scaling interface. The previously unused struct v4l2_cropcap and struct v4l2_crop where redefined for this purpose. See crop for details. -
In struct v4l2_vbi_format the
SAMPLE_FORMATfield now contains a four-character-code as used to identify video image formats andV4L2_PIX_FMT_GREYreplaces theV4L2_VBI_SF_UBYTEdefine. Thereservedfield was extended. -
In struct v4l2_captureparm the type of the
timeperframefield changed from unsigned long to struct v4l2_fract. This allows the accurate expression of multiples of the NTSC-M frame rate 30000 / 1001. A new fieldreadbufferswas added to control the driver behaviour in read I/O mode.Similar changes were made to struct v4l2_outputparm.
-
The struct
v4l2_performanceandVIDIOC_G_PERFioctl were dropped. Except when using the read/write I/O method, which is limited anyway, this information is already available to applications. -
The example transformation from RGB to YCbCr color space in the old V4L2 documentation was inaccurate, this has been corrected in pixfmt.
V4L2 2003-06-19 #
-
A new capability flag
V4L2_CAP_RADIOwas added for radio devices. Prior to this change radio devices would identify solely by having exactly one tuner whose type field readsV4L2_TUNER_RADIO. -
An optional driver access priority mechanism was added, see app-pri for details.
-
The audio input and output interface was found to be incomplete.
Previously the VIDIOC_G_AUDIO ioctl would enumerate the available audio inputs. An ioctl to determine the current audio input, if more than one combines with the current video input, did not exist. So
VIDIOC_G_AUDIOwas renamed toVIDIOC_G_AUDIO_OLD, this ioctl was removed on Kernel 2.6.39. The vidioc_enumaudio ioctl was added to enumerate audio inputs, while VIDIOC_G_AUDIO now reports the current audio input.The same changes were made to VIDIOC_G_AUDOUT and VIDIOC_ENUMAUDOUT.
Until further the "videodev" module will automatically translate between the old and new ioctls, but drivers and applications must be updated to successfully compile again.
-
The vidioc_overlay ioctl was incorrectly defined with write-read parameter. It was changed to write-only, while the write-read version was renamed to
VIDIOC_OVERLAY_OLD. The old ioctl was removed on Kernel 2.6.39. Until further the "videodev" kernel module will automatically translate to the new version, so drivers must be recompiled, but not applications. -
Video Overlay Interface incorrectly stated that clipping rectangles define regions where the video can be seen. Correct is that clipping rectangles define regions where no video shall be displayed and so the graphics surface can be seen.
-
The VIDIOC_S_PARM and VIDIOC_S_CTRL ioctls were defined with write-only parameter, inconsistent with other ioctls modifying their argument. They were changed to write-read, while a
_OLDsuffix was added to the write-only versions. The old ioctls were removed on Kernel 2.6.39. Drivers and applications assuming a constant parameter need an update.
V4L2 2003-11-05 #
-
In RGB Formats the following pixel formats were incorrectly transferred from Bill Dirks' V4L2 specification. Descriptions below refer to bytes in memory, in ascending address order.
Symbol
In this document prior to revision 0.5
Corrected
V4L2_PIX_FMT_RGB24B, G, R
R, G, B
V4L2_PIX_FMT_BGR24R, G, B
B, G, R
V4L2_PIX_FMT_RGB32B, G, R, X
R, G, B, X
V4L2_PIX_FMT_BGR32R, G, B, X
B, G, R, X
The
V4L2_PIX_FMT_BGR24example was always correct.In Image Properties the mapping of the V4L
VIDEO_PALETTE_RGB24andVIDEO_PALETTE_RGB32formats to V4L2 pixel formats was accordingly corrected. -
Unrelated to the fixes above, drivers may still interpret some V4L2 RGB pixel formats differently. These issues have yet to be addressed, for details see RGB Formats.
V4L2 in Linux 2.6.6, 2004-05-09 #
- The vidioc_cropcap ioctl was incorrectly defined with read-only parameter. It is now defined as write-read ioctl, while the read-only version was renamed to
VIDIOC_CROPCAP_OLD. The old ioctl was removed on Kernel 2.6.39.
V4L2 in Linux 2.6.8 #
- A new field
input(formerreserved[0]) was added to the struct v4l2_buffer. Purpose of this field is to alternate between video inputs (e. g. cameras) in step with the video capturing process. This function must be enabled with the newV4L2_BUF_FLAG_INPUTflag. Theflagsfield is no longer read-only.
V4L2 spec erratum 2004-08-01 #
-
The return value of the func-open function was incorrectly documented.
-
Audio output ioctls end in -AUDOUT, not -AUDIOOUT.
-
In the Current Audio Input example the
VIDIOC_G_AUDIOioctl took the wrong argument. -
The documentation of the vidioc_qbuf and VIDIOC_DQBUF ioctls did not mention the struct v4l2_buffer
memoryfield. It was also missing from examples. Also on theVIDIOC_DQBUFpage theEIOerror code was not documented.
V4L2 in Linux 2.6.14 #
- A new sliced VBI interface was added. It is documented in Sliced VBI Data Interface and replaces the interface first proposed in V4L2 specification 0.8.
V4L2 in Linux 2.6.15 #
-
The vidioc_log_status ioctl was added.
-
New video standards
V4L2_STD_NTSC_443,V4L2_STD_SECAM_LC,V4L2_STD_SECAM_DK(a set of SECAM D, K and K1), andV4L2_STD_ATSC(a set ofV4L2_STD_ATSC_8_VSBandV4L2_STD_ATSC_16_VSB) were defined. Note theV4L2_STD_525_60set now includesV4L2_STD_NTSC_443. See also v4l2-std-id. -
The
VIDIOC_G_COMPandVIDIOC_S_COMPioctl were renamed toVIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPrespectively. Their argument was replaced by a structv4l2_mpeg_compressionpointer. (TheVIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPioctls where removed in Linux 2.6.25.)
V4L2 spec erratum 2005-11-27 #
The capture example in capture-example called the VIDIOC_S_CROP ioctl without checking if cropping is supported. In the video standard selection example in standard the VIDIOC_S_STD call used the wrong argument type.
V4L2 spec erratum 2006-01-10 #
-
The
V4L2_IN_ST_COLOR_KILLflag in struct v4l2_input not only indicates if the color killer is enabled, but also if it is active. (The color killer disables color decoding when it detects no color in the video signal to improve the image quality.) -
VIDIOC_S_PARM is a write-read ioctl, not write-only as stated on its reference page. The ioctl changed in 2003 as noted above.
V4L2 spec erratum 2006-02-03 #
- In struct v4l2_captureparm and struct v4l2_outputparm the
timeperframefield gives the time in seconds, not microseconds.
V4L2 spec erratum 2006-02-04 #
- The
clipsfield in struct v4l2_window must point to an array of struct v4l2_clip, not a linked list, because drivers ignore the struct v4l2_clip.nextpointer.
V4L2 in Linux 2.6.17 #
-
New video standard macros were added:
V4L2_STD_NTSC_M_KR(NTSC M South Korea), and the setsV4L2_STD_MN,V4L2_STD_B,V4L2_STD_GHandV4L2_STD_DK. TheV4L2_STD_NTSCandV4L2_STD_SECAMsets now includeV4L2_STD_NTSC_M_KRandV4L2_STD_SECAM_LCrespectively. -
A new
V4L2_TUNER_MODE_LANG1_LANG2was defined to record both languages of a bilingual program. The use ofV4L2_TUNER_MODE_STEREOfor this purpose is deprecated now. See the VIDIOC_G_TUNER section for details.
V4L2 spec erratum 2006-09-23 (Draft 0.15) #
-
In various places
V4L2_BUF_TYPE_SLICED_VBI_CAPTUREandV4L2_BUF_TYPE_SLICED_VBI_OUTPUTof the sliced VBI interface were not mentioned along with other buffer types. -
In VIDIOC_G_AUDIO it was clarified that the struct v4l2_audio
modefield is a flags field. -
vidioc_querycap did not mention the sliced VBI and radio capability flags.
-
In VIDIOC_G_FREQUENCY it was clarified that applications must initialize the tuner
typefield of struct v4l2_frequency before calling VIDIOC_S_FREQUENCY. -
The
reservedarray in struct v4l2_requestbuffers has 2 elements, not 32. -
In output and raw-vbi the device file names
/dev/voutwhich never caught on were replaced by/dev/video. -
With Linux 2.6.15 the possible range for VBI device minor numbers was extended from 224-239 to 224-255. Accordingly device file names
/dev/vbi0to/dev/vbi31are possible now.
V4L2 in Linux 2.6.18 #
- New ioctls VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS were added, a flag to skip unsupported controls with ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU, new control types
V4L2_CTRL_TYPE_INTEGER64andV4L2_CTRL_TYPE_CTRL_CLASS(enum v4l2_ctrl_type), and new control flagsV4L2_CTRL_FLAG_READ_ONLY,V4L2_CTRL_FLAG_UPDATE,V4L2_CTRL_FLAG_INACTIVEandV4L2_CTRL_FLAG_SLIDER(control-flags). See extended-controls for details.
V4L2 in Linux 2.6.19 #
-
In struct v4l2_sliced_vbi_cap a buffer type field was added replacing a reserved field. Note on architectures where the size of enum types differs from int types the size of the structure changed. The VIDIOC_G_SLICED_VBI_CAP ioctl was redefined from being read-only to write-read. Applications must initialize the type field and clear the reserved fields now. These changes may break the compatibility with older drivers and applications.
-
The ioctls vidioc_enum_framesizes and vidioc_enum_frameintervals were added.
-
A new pixel format
V4L2_PIX_FMT_RGB444(RGB Formats) was added.
V4L2 spec erratum 2006-10-12 (Draft 0.17) #
V4L2_PIX_FMT_HM12(reserved-formats) is a YUV 4:2:0, not 4:2:2 format.
V4L2 in Linux 2.6.21 #
- The
videodev2.hheader file is now dual licensed under GNU General Public License version two or later, and under a 3-clause BSD-style license.
V4L2 in Linux 2.6.22 #
-
Two new field orders
V4L2_FIELD_INTERLACED_TBandV4L2_FIELD_INTERLACED_BTwere added. See enum v4l2_field for details. -
Three new clipping/blending methods with a global or straight or inverted local alpha value were added to the video overlay interface. See the description of the VIDIOC_G_FBUF and VIDIOC_S_FBUF ioctls for details.
A new
global_alphafield was added to struct v4l2_window, extending the structure. This may break compatibility with applications using a struct v4l2_window directly. However the VIDIOC_G/S/TRY_FMT ioctls, which take a pointer to a struct v4l2_format parent structure with padding bytes at the end, are not affected. -
The format of the
chromakeyfield in struct v4l2_window changed from "host order RGB32" to a pixel value in the same format as the framebuffer. This may break compatibility with existing applications. Drivers supporting the "host order RGB32" format are not known.
V4L2 in Linux 2.6.24 #
- The pixel formats
V4L2_PIX_FMT_PAL8,V4L2_PIX_FMT_YUV444,V4L2_PIX_FMT_YUV555,V4L2_PIX_FMT_YUV565andV4L2_PIX_FMT_YUV32were added.
V4L2 in Linux 2.6.25 #
-
The pixel formats V4L2_PIX_FMT_Y16 and V4L2_PIX_FMT_SBGGR16 were added.
-
New controls
V4L2_CID_POWER_LINE_FREQUENCY,V4L2_CID_HUE_AUTO,V4L2_CID_WHITE_BALANCE_TEMPERATURE,V4L2_CID_SHARPNESSandV4L2_CID_BACKLIGHT_COMPENSATIONwere added. The controlsV4L2_CID_BLACK_LEVEL,V4L2_CID_WHITENESS,V4L2_CID_HCENTERandV4L2_CID_VCENTERwere deprecated. -
A Camera controls class was added, with the new controls
V4L2_CID_EXPOSURE_AUTO,V4L2_CID_EXPOSURE_ABSOLUTE,V4L2_CID_EXPOSURE_AUTO_PRIORITY,V4L2_CID_PAN_RELATIVE,V4L2_CID_TILT_RELATIVE,V4L2_CID_PAN_RESET,V4L2_CID_TILT_RESET,V4L2_CID_PAN_ABSOLUTE,V4L2_CID_TILT_ABSOLUTE,V4L2_CID_FOCUS_ABSOLUTE,V4L2_CID_FOCUS_RELATIVEandV4L2_CID_FOCUS_AUTO. -
The
VIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPioctls, which were superseded by the extended controls interface in Linux 2.6.18, where finally removed from thevideodev2.hheader file.
V4L2 in Linux 2.6.26 #
-
The pixel formats
V4L2_PIX_FMT_Y16andV4L2_PIX_FMT_SBGGR16were added. -
Added user controls
V4L2_CID_CHROMA_AGCandV4L2_CID_COLOR_KILLER.
V4L2 in Linux 2.6.27 #
-
The vidioc_s_hw_freq_seek ioctl and the
V4L2_CAP_HW_FREQ_SEEKcapability were added. -
The pixel formats
V4L2_PIX_FMT_YVYU,V4L2_PIX_FMT_PCA501,V4L2_PIX_FMT_PCA505,V4L2_PIX_FMT_PCA508,V4L2_PIX_FMT_PCA561,V4L2_PIX_FMT_SGBRG8,V4L2_PIX_FMT_PAC207andV4L2_PIX_FMT_PJPGwere added.
V4L2 in Linux 2.6.28 #
-
Added
V4L2_MPEG_AUDIO_ENCODING_AACandV4L2_MPEG_AUDIO_ENCODING_AC3MPEG audio encodings. -
Added
V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVCMPEG video encoding. -
The pixel formats
V4L2_PIX_FMT_SGRBG10andV4L2_PIX_FMT_SGRBG10DPCM8were added.
V4L2 in Linux 2.6.29 #
-
The
VIDIOC_G_CHIP_IDENTioctl was renamed toVIDIOC_G_CHIP_IDENT_OLDandVIDIOC_DBG_G_CHIP_IDENTwas introduced in its place. The old structv4l2_chip_identwas renamed to structv4l2_chip_ident_old. -
The pixel formats
V4L2_PIX_FMT_VYUY,V4L2_PIX_FMT_NV16andV4L2_PIX_FMT_NV61were added. -
Added camera controls
V4L2_CID_ZOOM_ABSOLUTE,V4L2_CID_ZOOM_RELATIVE,V4L2_CID_ZOOM_CONTINUOUSandV4L2_CID_PRIVACY.
V4L2 in Linux 2.6.30 #
-
New control flag
V4L2_CTRL_FLAG_WRITE_ONLYwas added. -
New control
V4L2_CID_COLORFXwas added.
V4L2 in Linux 2.6.32 #
-
In order to be easier to compare a V4L2 API and a kernel version, now V4L2 API is numbered using the Linux Kernel version numeration.
-
Finalized the RDS capture API. See rds for more information.
-
Added new capabilities for modulators and RDS encoders.
-
Add description for libv4l API.
-
Added support for string controls via new type
V4L2_CTRL_TYPE_STRING. -
Added
V4L2_CID_BAND_STOP_FILTERdocumentation. -
Added FM Modulator (FM TX) Extended Control Class:
V4L2_CTRL_CLASS_FM_TXand their Control IDs. -
Added FM Receiver (FM RX) Extended Control Class:
V4L2_CTRL_CLASS_FM_RXand their Control IDs. -
Added Remote Controller chapter, describing the default Remote Controller mapping for media devices.
V4L2 in Linux 2.6.33 #
- Added support for Digital Video timings in order to support HDTV receivers and transmitters.
V4L2 in Linux 2.6.34 #
- Added
V4L2_CID_IRIS_ABSOLUTEandV4L2_CID_IRIS_RELATIVEcontrols to the Camera controls class.
V4L2 in Linux 2.6.37 #
- Remove the vtx (videotext/teletext) API. This API was no longer used and no hardware exists to verify the API. Nor were any userspace applications found that used it. It was originally scheduled for removal in 2.6.35.
V4L2 in Linux 2.6.39 #
-
The old VIDIOC_*_OLD symbols and V4L1 support were removed.
-
Multi-planar API added. Does not affect the compatibility of current drivers and applications. See multi-planar API for details.
V4L2 in Linux 3.1 #
-
VIDIOC_QUERYCAP now returns a per-subsystem version instead of a per-driver one.
Standardize an error code for invalid ioctl.
Added V4L2_CTRL_TYPE_BITMASK.
V4L2 in Linux 3.2 #
-
V4L2_CTRL_FLAG_VOLATILE was added to signal volatile controls to userspace.
-
Add selection API for extended control over cropping and composing. Does not affect the compatibility of current drivers and applications. See selection API for details.
V4L2 in Linux 3.3 #
-
Added
V4L2_CID_ALPHA_COMPONENTcontrol to the User controls class. -
Added the device_caps field to struct v4l2_capabilities and added the new V4L2_CAP_DEVICE_CAPS capability.
V4L2 in Linux 3.4 #
-
Extended the DV Timings API: vidioc_enum_dv_timings, vidioc_query_dv_timings and vidioc_dv_timings_cap.
V4L2 in Linux 3.5 #
-
Added integer menus, the new type will be V4L2_CTRL_TYPE_INTEGER_MENU.
-
Added selection API for V4L2 subdev interface: vidioc_subdev_g_selection and VIDIOC_SUBDEV_S_SELECTION.
-
Added
V4L2_COLORFX_ANTIQUE,V4L2_COLORFX_ART_FREEZE,V4L2_COLORFX_AQUA,V4L2_COLORFX_SILHOUETTE,V4L2_COLORFX_SOLARIZATION,V4L2_COLORFX_VIVIDandV4L2_COLORFX_ARBITRARY_CBCRmenu items to theV4L2_CID_COLORFXcontrol. -
Added
V4L2_CID_COLORFX_CBCRcontrol. -
Added camera controls
V4L2_CID_AUTO_EXPOSURE_BIAS,V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE,V4L2_CID_IMAGE_STABILIZATION,V4L2_CID_ISO_SENSITIVITY,V4L2_CID_ISO_SENSITIVITY_AUTO,V4L2_CID_EXPOSURE_METERING,V4L2_CID_SCENE_MODE,V4L2_CID_3A_LOCK,V4L2_CID_AUTO_FOCUS_START,V4L2_CID_AUTO_FOCUS_STOP,V4L2_CID_AUTO_FOCUS_STATUSandV4L2_CID_AUTO_FOCUS_RANGE.
V4L2 in Linux 3.6 #
-
Replaced
inputin struct v4l2_buffer byreserved2and removedV4L2_BUF_FLAG_INPUT. -
Added V4L2_CAP_VIDEO_M2M and V4L2_CAP_VIDEO_M2M_MPLANE capabilities.
-
Added support for frequency band enumerations: vidioc_enum_freq_bands.
V4L2 in Linux 3.9 #
-
Added timestamp types to
flagsfield in struct v4l2_buffer. See Buffer Flags. -
Added
V4L2_EVENT_CTRL_CH_RANGEcontrol event changes flag. See ctrl-changes-flags.
V4L2 in Linux 3.10 #
-
Removed obsolete and unused DV_PRESET ioctls VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET, VIDIOC_QUERY_DV_PRESET and VIDIOC_ENUM_DV_PRESET. Remove the related v4l2_input/output capability flags V4L2_IN_CAP_PRESETS and V4L2_OUT_CAP_PRESETS.
-
Added new debugging ioctl vidioc_dbg_g_chip_info.
V4L2 in Linux 3.11 #
- Remove obsolete
VIDIOC_DBG_G_CHIP_IDENTioctl.
V4L2 in Linux 3.14 #
- In struct v4l2_rect, the type of
widthandheightfields changed from _s32 to _u32.
V4L2 in Linux 3.15 #
- Added Software Defined Radio (SDR) Interface.
V4L2 in Linux 3.16 #
- Added event V4L2_EVENT_SOURCE_CHANGE.
V4L2 in Linux 3.17 #
-
Extended struct v4l2_pix_format. Added format flags.
-
Added compound control types and VIDIOC_QUERY_EXT_CTRL.
V4L2 in Linux 3.18 #
- Added
V4L2_CID_PAN_SPEEDandV4L2_CID_TILT_SPEEDcamera controls.
V4L2 in Linux 3.19 #
- Rewrote Colorspace chapter, added new enum v4l2_ycbcr_encoding and enum v4l2_quantization fields to struct v4l2_pix_format, struct v4l2_pix_format_mplane and struct v4l2_mbus_framefmt.
V4L2 in Linux 4.4 #
-
Renamed
V4L2_TUNER_ADCtoV4L2_TUNER_SDR. The use ofV4L2_TUNER_ADCis deprecated now. -
Added
V4L2_CID_RF_TUNER_RF_GAINRF Tuner control. -
Added transmitter support for Software Defined Radio (SDR) Interface.
Relation of V4L2 to other Linux multimedia APIs #
X Video Extension #
The X Video Extension (abbreviated XVideo or just Xv) is an extension of the X Window system, implemented for example by the XFree86 project. Its scope is similar to V4L2, an API to video capture and output devices for X clients. Xv allows applications to display live video in a window, send window contents to a TV output, and capture or output still images in XPixmaps 1. With their implementation XFree86 makes the extension available across many operating systems and architectures.
Because the driver is embedded into the X server Xv has a number of advantages over the V4L2 video overlay interface. The driver can easily determine the overlay target, i. e. visible graphics memory or off-screen buffers for a destructive overlay. It can program the RAMDAC for a non-destructive overlay, scaling or color-keying, or the clipping functions of the video capture hardware, always in sync with drawing operations or windows moving or changing their stacking order.
To combine the advantages of Xv and V4L a special Xv driver exists in XFree86 and XOrg, just programming any overlay capable Video4Linux device it finds. To enable it /etc/X11/XF86Config must contain these lines:
Section "Module"
Load "v4l"
EndSection
As of XFree86 4.2 this driver still supports only V4L ioctls, however it should work just fine with all V4L2 devices through the V4L2 backward-compatibility layer. Since V4L2 permits multiple opens it is possible (if supported by the V4L2 driver) to capture video while an X client requested video overlay. Restrictions of simultaneous capturing and overlay are discussed in Video Overlay Interface apply.
Only marginally related to V4L2, XFree86 extended Xv to support hardware YUV to RGB conversion and scaling for faster video playback, and added an interface to MPEG-2 decoding hardware. This API is useful to display images captured with V4L2 devices.
Digital Video #
V4L2 does not support digital terrestrial, cable or satellite broadcast. A separate project aiming at digital receivers exists. You can find its homepage at https://linuxtv.org. The Linux DVB API has no connection to the V4L2 API except that drivers for hybrid hardware may support both.
Audio Interfaces #
[to do - OSS/ALSA]
Experimental API Elements #
The following V4L2 API elements are currently experimental and may change in the future.
-
vidioc_dbg_g_register and VIDIOC_DBG_S_REGISTER ioctls.
-
vidioc_dbg_g_chip_info ioctl.
Obsolete API Elements #
The following V4L2 API elements were superseded by new interfaces and should not be implemented in new drivers.
-
VIDIOC_G_MPEGCOMPandVIDIOC_S_MPEGCOMPioctls. Use Extended Controls, extended-controls. -
VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET, VIDIOC_ENUM_DV_PRESETS and VIDIOC_QUERY_DV_PRESET ioctls. Use the DV Timings API (dv-timings).
-
VIDIOC_SUBDEV_G_CROPandVIDIOC_SUBDEV_S_CROPioctls. UseVIDIOC_SUBDEV_G_SELECTIONandVIDIOC_SUBDEV_S_SELECTION, vidioc_subdev_g_selection.
[1] This is not implemented in XFree86.
HSV Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
These formats store the color information of the image in a geometrical representation. The colors are mapped into a cylinder, where the angle is the HUE, the height is the VALUE and the distance to the center is the SATURATION. This is a very useful format for image segmentation algorithms.
Input/Output
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The V4L2 API defines several different methods to read from or write to a device. All drivers exchanging data with applications must support at least one of them.
The classic I/O method using the read() and write() function is automatically selected after opening a V4L2 device. When the driver does not support this method attempts to read or write will fail at any time.
Other methods must be negotiated. To select the streaming I/O method with memory mapped or user buffers applications call the vidioc_reqbufs ioctl.
Video overlay can be considered another I/O method, although the application does not directly receive the image data. It is selected by initiating video overlay with the VIDIOC_S_FMT ioctl. For more information see Video Overlay Interface.
Generally exactly one I/O method, including overlay, is associated with each file descriptor. The only exceptions are applications not exchanging data with a driver ("panel applications", see Opening and Closing Devices) and drivers permitting simultaneous video capturing and overlay using the same file descriptor, for compatibility with V4L and earlier versions of V4L2.
VIDIOC_S_FMT and vidioc_reqbufs would permit this to some degree, but for simplicity drivers need not support switching the I/O method (after first switching away from read/write) other than by closing and reopening the device.
The following sections describe the various I/O methods in more detail.
Introduction
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
libv4l is a collection of libraries which adds a thin abstraction layer on top of video4linux2 devices. The purpose of this (thin) layer is to make it easy for application writers to support a wide variety of devices without having to write separate code for different devices in the same class.
An example of using libv4l is provided by v4l2grab.
libv4l consists of 3 different libraries:
libv4lconvert #
libv4lconvert is a library that converts several different pixelformats found in V4L2 drivers into a few common RGB and YUY formats.
It currently accepts the following V4L2 driver formats: V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_NV12_16L16, V4L2_PIX_FMT_JPEG, V4L2_PIX_FMT_MJPEG, V4L2_PIX_FMT_MR97310A, V4L2_PIX_FMT_OV511, V4L2_PIX_FMT_OV518, V4L2_PIX_FMT_PAC207, V4L2_PIX_FMT_PJPG, V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_SBGGR8, V4L2_PIX_FMT_SGBRG8, V4L2_PIX_FMT_SGRBG8, V4L2_PIX_FMT_SN9C10X, V4L2_PIX_FMT_SN9C20X_I420, V4L2_PIX_FMT_SPCA501, V4L2_PIX_FMT_SPCA505, V4L2_PIX_FMT_SPCA508, V4L2_PIX_FMT_SPCA561, V4L2_PIX_FMT_SQ905C, V4L2_PIX_FMT_SRGGB8, V4L2_PIX_FMT_UYVY, V4L2_PIX_FMT_YUV420, V4L2_PIX_FMT_YUYV, V4L2_PIX_FMT_YVU420, and V4L2_PIX_FMT_YVYU.
Later on libv4lconvert was expanded to also be able to do various video processing functions to improve webcam video quality. The video processing is split in to 2 parts: libv4lconvert/control and libv4lconvert/processing.
The control part is used to offer video controls which can be used to control the video processing functions made available by libv4lconvert/processing. These controls are stored application wide (until reboot) by using a persistent shared memory object.
libv4lconvert/processing offers the actual video processing functionality.
libv4l1 #
This library offers functions that can be used to quickly make v4l1 applications work with v4l2 devices. These functions work exactly like the normal open/close/etc, except that libv4l1 does full emulation of the v4l1 api on top of v4l2 drivers, in case of v4l1 drivers it will just pass calls through.
Since those functions are emulations of the old V4L1 API, it shouldn't be used for new applications.
libv4l2 #
This library should be used for all modern V4L2 applications.
It provides handles to call V4L2 open/ioctl/close/poll methods. Instead of just providing the raw output of the device, it enhances the calls in the sense that it will use libv4lconvert to provide more video formats and to enhance the image quality.
In most cases, libv4l2 just passes the calls directly through to the v4l2 driver, intercepting the calls to VIDIOC_TRY_FMT, VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS in order to emulate the formats V4L2_PIX_FMT_BGR24, V4L2_PIX_FMT_RGB24, V4L2_PIX_FMT_YUV420, and V4L2_PIX_FMT_YVU420, if they aren't available in the driver. VIDIOC_ENUM_FMT keeps enumerating the hardware supported formats, plus the emulated formats offered by libv4l at the end.
Libv4l device control functions #
The common file operation methods are provided by libv4l.
Those functions operate just like the gcc function dup() and V4L2 functions open(), close(), ioctl(), read(), mmap() and munmap():
int operates like the open() function.
int operates like the close() function.
int operates like the libc dup() function, duplicating a file handler.
int operates like the ioctl() function.
int operates like the read() function.
void *;
operates like the mmap() function.
int ;
operates like the munmap() function.
Those functions provide additional control:
int opens an already opened fd for further use through v4l2lib and possibly modify libv4l2's default behavior through the v4l2_flags argument. Currently, v4l2_flags can be V4L2_DISABLE_CONVERSION, to disable format conversion.
int This function takes a value of 0 - 65535, and then scales that range to the actual range of the given v4l control id, and then if the cid exists and is not locked sets the cid to the scaled value.
int This function returns a value of 0 - 65535, scaled to from the actual range of the given v4l control id. when the cid does not exist, could not be accessed for some reason, or some error occurred 0 is returned.
v4l1compat.so wrapper library #
This library intercepts calls to open(), close(), ioctl(), mmap() and munmap() operations and redirects them to the libv4l counterparts, by using LD_PRELOAD=/usr/lib/v4l1compat.so. It also emulates V4L1 calls via V4L2 API.
It allows usage of binary legacy applications that still don't use libv4l.
Libv4l Userspace Library
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Metadata Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
These formats are used for the Metadata Interface interface only.
- V4L2_META_FMT_MALI_C55_STATS ('C55S'), V4L2_META_FMT_MALI_C55_PARAMS ('C55P')
- V4L2_META_FMT_C3ISP_STATS ('C3ST'), V4L2_META_FMT_C3ISP_PARAMS ('C3PM')
- V4L2_META_FMT_D4XX ('D4XX')
- metafmt-generic
- V4L2_META_FMT_IPU3_PARAMS ('ip3p'), V4L2_META_FMT_IPU3_3A ('ip3s')
- V4L2_META_FMT_RPI_BE_CFG
- V4L2_META_FMT_RPI_FE_CFG
- V4L2_META_FMT_RK_ISP1_PARAMS ('rk1p'), V4L2_META_FMT_RK_ISP1_STAT_3A ('rk1s'), V4L2_META_FMT_RK_ISP1_EXT_PARAMS ('rk1e')
- V4L2_META_FMT_UVC ('UVCH')
- V4L2_META_FMT_UVC_MSXU_1_5 ('UVCM')
- V4L2_META_FMT_VIVID ('VIVD')
- V4L2_META_FMT_VSP1_HGO ('VSPH')
- metafmt-vsp1-hgt
- Generic V4L2 ISP formats
V4L2_META_FMT_MALI_C55_STATS ('C55S'), V4L2_META_FMT_MALI_C55_PARAMS ('C55P')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
3A Statistics #
The ISP device collects different statistics over an input bayer frame. Those statistics can be obtained by userspace from the mali-c55 3a stats metadata capture video node, using the v4l2_meta_format interface. The buffer contains a single instance of the C structure mali_c55_stats_buffer defined in mali-c55-config.h, so the structure can be obtained from the buffer by:
struct mali_c55_stats_buffer *stats =
buf;
For details of the statistics see mali_c55_stats_buffer.
Configuration Parameters #
The configuration parameters are passed to the mali-c55 3a params metadata output video node, using the v4l2_meta_format interface. Rather than a single struct containing sub-structs for each configurable area of the ISP, parameters for the Mali-C55 use the v4l2-isp parameters system, through which groups of parameters are defined as distinct structs or "blocks" which may be added to the data member of v4l2_isp_params_buffer. Userspace is responsible for populating the data member with the blocks that need to be configured by the driver. Each block-specific struct embeds v4l2_isp_params_block_header as its first member and userspace must populate the type member with a value from mali_c55_param_block_type.
struct v4l2_isp_params_buffer *params =
buffer;
params->version = V4L2_ISP_PARAMS_VERSION_V1;
params->data_size = 0;
void *data = params->data;
struct mali_c55_params_awb_gains *gains =
data;
gains->header.type = MALI_C55_PARAM_BLOCK_AWB_GAINS;
gains->header.flags |= V4L2_ISP_PARAMS_FL_BLOCK_ENABLE;
gains->header.size = sizeof;
gains->gain00 = 256;
gains->gain00 = 256;
gains->gain00 = 256;
gains->gain00 = 256;
data += sizeof;
params->data_size += sizeof;
struct mali_c55_params_sensor_off_preshading *blc =
data;
blc->header.type = MALI_C55_PARAM_BLOCK_SENSOR_OFFS;
blc->header.flags |= V4L2_ISP_PARAMS_FL_BLOCK_ENABLE;
blc->header.size = sizeof;
blc->chan00 = 51200;
blc->chan01 = 51200;
blc->chan10 = 51200;
blc->chan11 = 51200;
params->data_size += sizeof;
Arm Mali-C55 uAPI data types #
struct mali_c55_ae_1024bin_hist #
Auto Exposure 1024-bin histogram statistics
Definition
;
Members
bins: 1024 element array of 16-bit pixel counts.
Description
The 1024-bin histogram module collects image-global but zone-weighted intensity distributions of pixels in fixed-width bins. The modules can be configured into different "plane modes" which affect the contents of the collected statistics. In plane mode 0, pixel intensities are taken regardless of colour plane into a single 1024-bin histogram with a bin width of 4. In plane mode 1, four 256-bin histograms with a bin width of 16 are collected - one for each CFA colour plane. In plane modes 4, 5, 6 and 7 two 512-bin histograms with a bin width of 8 are collected - in each mode one of the colour planes is collected into the first histogram and all the others are combined into the second. The histograms are stored consecutively in the bins array.
The 16-bit pixel counts are stored as a 4-bit exponent in the most significant bits followed by a 12-bit mantissa. Conversion to a usable format can be done according to the following pseudo-code:
if (e == 0) {
bin = m * 2;
} else {
bin = (m + 4096) * 2^e
}
- where: e is the exponent value in range 0..15 m is the mantissa value in range 0..4095
The pixels used in calculating the statistics can be masked using three methods:
- Pixels can be skipped in X and Y directions independently.
- Minimum/Maximum intensities can be configured
- Zones can be differentially weighted, including 0 weighted to mask them
The data for this histogram can be collected from different tap points in the ISP depending on configuration - after the white balance or digital gain blocks, or immediately after the input crossbar.
struct mali_c55_ae_5bin_hist #
Auto Exposure 5-bin histogram statistics
Definition
;
Members
hist0: 16-bit normalised pixel count for the 0th intensity binhist1: 16-bit normalised pixel count for the 1st intensity binhist3: 16-bit normalised pixel count for the 3rd intensity binhist4: 16-bit normalised pixel count for the 4th intensity bin
Description
The ISP generates a 5-bin histogram of normalised pixel counts within bins of pixel intensity for each of 225 possible zones within a frame. The centre bin of the histogram for each zone is not available from the hardware and must be calculated by subtracting the values of hist0, hist1, hist3 and hist4 from 0xffff as in the following equation:
hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4)
struct mali_c55_awb_average_ratios #
Auto White Balance colour ratios
Definition
;
Members
avg_rg_gr: Average R/G or G/R ratio in Q4.8 format.avg_bg_br: Average B/G or B/R ratio in Q4.8 format.num_pixels: The number of pixels used in the AWB calculation
Description
The ISP calculates and collects average colour ratios for each zone in an image and stores them in Q4.8 format (the lowest 8 bits are fractional, with bits [11:8] representing the integer). The exact ratios collected (either R/G, B/G or G/R, B/R) are configurable through the parameters buffer. The value of the 4 high bits is undefined.
struct mali_c55_af_statistics #
Auto Focus edge and intensity statistics
Definition
;
Members
intensity_stats: Packed mantissa and exponent value for pixel intensityedge_stats: Packed mantissa and exponent values for edge intensity
Description
The ISP collects the squared sum of pixel intensities for each zone within a configurable Region of Interest on the frame. Additionally, the same data are collected after being passed through a bandpass filter which removes high and low frequency components - these are referred to as the edge statistics.
The intensity and edge statistics for a zone can be used to calculate the contrast information for a zone
C = E2 / I2
Where I2 is the intensity statistic for a zone and E2 is the edge statistic for that zone. Optimum focus is reached when C is at its maximum.
The intensity and edge statistics are stored packed into a non-standard 16 bit floating point format, where the 7 most significant bits represent the exponent and the 9 least significant bits the mantissa. This format can be unpacked with the following pseudocode:
if (e == 0) {
x = m;
} else {
x = 2^e-1 * (m + 2^9)
}
- where: e is the exponent value in range 0..127 m is the mantissa value in range 0..511
struct mali_c55_stats_buffer #
3A statistics for the mali-c55 ISP
Definition
;
Members
ae_1024bin_hist: 1024-bin frame-global pixel intensity histogramiridix_1024bin_hist: Post-Iridix block 1024-bin histogramae_5bin_hists: 5-bin pixel intensity histograms for AECreserved1: Undefined buffer spaceawb_ratios: Color balance ratios for Auto White Balancereserved2: Undefined buffer spaceaf_statistics: Pixel intensity statistics for Auto Focusreserved3: Undefined buffer space
Description
This struct describes the metering statistics space in the Mali-C55 ISP's hardware in its entirety. The space between each defined area is marked as "unknown" and may not be 0, but should not be used. The ae_5bin_hists, awb_ratios and af_statistics members are arrays of statistics per-zone. The zones are arranged in the array in raster order starting from the top left corner of the image.
enum mali_c55_param_block_type #
Enumeration of Mali-C55 parameter blocks
Constants
MALI_C55_PARAM_BLOCK_SENSOR_OFFS: Sensor pre-shading black level offsetMALI_C55_PARAM_BLOCK_AEXP_HIST: Auto-exposure 1024-bin histogram configurationMALI_C55_PARAM_BLOCK_AEXP_IHIST: Post-Iridix auto-exposure 1024-bin histogram configurationMALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS: Auto-exposure 1024-bin histogram weightingMALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS: Post-Iridix auto-exposure 1024-bin histogram weightingMALI_C55_PARAM_BLOCK_DIGITAL_GAIN: Digital gainMALI_C55_PARAM_BLOCK_AWB_GAINS: Auto-white balance gainsMALI_C55_PARAM_BLOCK_AWB_CONFIG: Auto-white balance statistics configMALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP: Auto-white balance gains for AEXP-0 tapMALI_C55_PARAM_MESH_SHADING_CONFIG: Mesh shading tables configurationMALI_C55_PARAM_MESH_SHADING_SELECTION: Mesh shading table selection
Description
This enumeration defines the types of Mali-C55 parameters block. Each block configures a specific processing block of the Mali-C55 ISP. The block type allows the driver to correctly interpret the parameters block data.
It is the responsibility of userspace to correctly set the type of each parameters block.
struct mali_c55_params_sensor_off_preshading #
offset subtraction for each color channel
Definition
;
Members
header: The Mali-C55 parameters block headerchan00: Offset for color channel 00 (default: R)chan01: Offset for color channel 01 (default: Gr)chan10: Offset for color channel 10 (default: Gb)chan11: Offset for color channel 11 (default: B)
Description
Provides removal of the sensor black level from the sensor data. Separate offsets are provided for each of the four Bayer component color channels which are defaulted to R, Gr, Gb, B.
header.type should be set to MALI_C55_PARAM_BLOCK_SENSOR_OFFS from
mali_c55_param_block_type for this block.
enum mali_c55_aexp_hist_tap_points #
Tap points for the AEXP histogram
Constants
MALI_C55_AEXP_HIST_TAP_WB: After static white balanceMALI_C55_AEXP_HIST_TAP_FS: After WDR Frame StitchMALI_C55_AEXP_HIST_TAP_TPG: After the test pattern generator
enum mali_c55_aexp_skip_x #
Horizontal pixel skipping
Constants
MALI_C55_AEXP_SKIP_X_EVERY_2ND: Collect every 2nd pixel horizontallyMALI_C55_AEXP_SKIP_X_EVERY_3RD: Collect every 3rd pixel horizontallyMALI_C55_AEXP_SKIP_X_EVERY_4TH: Collect every 4th pixel horizontallyMALI_C55_AEXP_SKIP_X_EVERY_5TH: Collect every 5th pixel horizontallyMALI_C55_AEXP_SKIP_X_EVERY_8TH: Collect every 8th pixel horizontallyMALI_C55_AEXP_SKIP_X_EVERY_9TH: Collect every 9th pixel horizontally
enum mali_c55_aexp_skip_y #
Vertical pixel skipping
Constants
MALI_C55_AEXP_SKIP_Y_ALL: Collect every single pixel verticallyMALI_C55_AEXP_SKIP_Y_EVERY_2ND: Collect every 2nd pixel verticallyMALI_C55_AEXP_SKIP_Y_EVERY_3RD: Collect every 3rd pixel verticallyMALI_C55_AEXP_SKIP_Y_EVERY_4TH: Collect every 4th pixel verticallyMALI_C55_AEXP_SKIP_Y_EVERY_5TH: Collect every 5th pixel verticallyMALI_C55_AEXP_SKIP_Y_EVERY_8TH: Collect every 8th pixel verticallyMALI_C55_AEXP_SKIP_Y_EVERY_9TH: Collect every 9th pixel vertically
enum mali_c55_aexp_row_column_offset #
Start from the first or second row or column
Constants
MALI_C55_AEXP_FIRST_ROW_OR_COL: Start from the first row / columnMALI_C55_AEXP_SECOND_ROW_OR_COL: Start from the second row / column
enum mali_c55_aexp_hist_plane_mode #
Mode for the AEXP Histograms
Constants
MALI_C55_AEXP_HIST_COMBINED: All color planes in one 1024-bin histogramMALI_C55_AEXP_HIST_SEPARATE: Each color plane in one 256-bin histogram with a bin width of 16MALI_C55_AEXP_HIST_FOCUS_00: Top left plane in the first bank, rest in second bankMALI_C55_AEXP_HIST_FOCUS_01: Top right plane in the first bank, rest in second bankMALI_C55_AEXP_HIST_FOCUS_10: Bottom left plane in the first bank, rest in second bankMALI_C55_AEXP_HIST_FOCUS_11: Bottom right plane in the first bank, rest in second bank
Description
In the "focus" modes statistics are collected into two 512-bin histograms with a bin width of 8. One colour plane is in the first histogram with the remainder combined into the second. The four options represent which of the four positions in a bayer pattern are the focused plane.
struct mali_c55_params_aexp_hist #
configuration for AEXP metering hists
Definition
;
Members
header: The Mali-C55 parameters block headerskip_x: Horizontal decimation. See enum mali_c55_aexp_skip_xoffset_x: Skip the first column, or not. See enum mali_c55_aexp_row_column_offsetskip_y: Vertical decimation. See enum mali_c55_aexp_skip_yoffset_y: Skip the first row, or not. See enum mali_c55_aexp_row_column_offsetscale_bottom: Scale pixels in bottom half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16xscale_top: scale pixels in top half of intensity range: 0=1x ,1=2x, 2=4x, 4=8x, 4=16xplane_mode: Plane separation mode. See enum mali_c55_aexp_hist_plane_modetap_point: Tap point for histogram from enum mali_c55_aexp_hist_tap_points. This parameter is unused for the post-Iridix Histogram
Description
This struct allows users to configure the 1024-bin AEXP histograms. Broadly speaking the parameters allow you to mask particular regions of the image and to select different kinds of histogram.
The skip_x, offset_x, skip_y and offset_y fields allow users to ignore or mask pixels in the frame by their position relative to the top left pixel. First, the skip_y, offset_x and offset_y fields define which of the pixels within each 2x2 region will be counted in the statistics.
If skip_y == 0 then two pixels from each covered region will be counted. If both offset_x and offset_y are zero, then the two left-most pixels in each 2x2 pixel region will be counted. Setting offset_x = 1 will discount the top left pixel and count the top right pixel. Setting offset_y = 1 will discount the bottom left pixel and count the bottom right pixel.
If skip_y != 0 then only a single pixel from each region covered by the pattern will be counted. In this case offset_x controls whether the pixel that's counted is in the left (if offset_x == 0) or right (if offset_x == 1) column and offset_y controls whether the pixel that's counted is in the top (if offset_y == 0) or bottom (if offset_y == 1) row.
The skip_x and skip_y fields control how the 2x2 pixel region is repeated across the image data. The first instance of the region is always in the top left of the image data. The skip_x field controls how many pixels are ignored in the x direction before the pixel masking region is repeated. The skip_y field controls how many pixels are ignored in the y direction before the pixel masking region is repeated.
These fields can be used to reduce the number of pixels counted for the statistics, but it's important to be careful to configure them correctly. Some combinations of values will result in colour components from the input data being ignored entirely, for example in the following configuration:
skip_x = 0 offset_x = 0 skip_y = 0 offset_y = 0
Only the R and Gb components of RGGB data that was input would be collected. Similarly in the following configuration:
skip_x = 0 offset_x = 0 skip_y = 1 offset_y = 1
Only the Gb component of RGGB data that was input would be collected. To correct things such that all 4 colour components were included it would be necessary to set the skip_x and skip_y fields in a way that resulted in all four colour components being collected:
skip_x = 1 offset_x = 0 skip_y = 1 offset_y = 1
header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST or
MALI_C55_PARAM_BLOCK_AEXP_IHIST from mali_c55_param_block_type.
struct mali_c55_params_aexp_weights #
Array of weights for AEXP metering
Definition
;
Members
header: The Mali-C55 parameters block headernodes_used_horiz: Number of active zones horizontally [0..15]nodes_used_vert: Number of active zones vertically [0..15]zone_weights: Zone weighting. Index is row*col where 0,0 is the top left zone continuing in raster order. Each zone can be weighted in the range [0..15]. The number of rows and columns is defined by nodes_used_vert and nodes_used_horiz
Description
This struct allows users to configure the weighting for both of the 1024-bin AEXP histograms. The pixel data collected for each zone is multiplied by the corresponding weight from this array, which may be zero if the intention is to mask off the zone entirely.
header.type should be set to one of either MALI_C55_PARAM_BLOCK_AEXP_HIST_WEIGHTS
or MALI_C55_PARAM_BLOCK_AEXP_IHIST_WEIGHTS from mali_c55_param_block_type.
struct mali_c55_params_digital_gain #
Digital gain value
Definition
;
Members
header: The Mali-C55 parameters block headergain: The digital gain value to apply, in Q5.8 format.
Description
This struct carries a digital gain value to set in the ISP.
header.type should be set to MALI_C55_PARAM_BLOCK_DIGITAL_GAIN from
mali_c55_param_block_type for this block.
enum mali_c55_awb_stats_mode #
Statistics mode for AWB
Constants
MALI_C55_AWB_MODE_GRBR: Statistics collected as Green/Red and Blue/Red ratiosMALI_C55_AWB_MODE_RGBG: Statistics collected as Red/Green and Blue/Green ratios
struct mali_c55_params_awb_gains #
Gain settings for auto white balance
Definition
;
Members
header: The Mali-C55 parameters block headergain00: Multiplier for colour channel 00gain01: Multiplier for colour channel 01gain10: Multiplier for colour channel 10gain11: Multiplier for colour channel 11
Description
This struct allows users to configure the gains for auto-white balance. There are four gain settings corresponding to each colour channel in the bayer domain. Although named generically, the association between the gain applied and the colour channel is done automatically within the ISP depending on the input format, and so the following mapping always holds true:
gain00 = R
gain01 = Gr
gain10 = Gb
gain11 = B
All of the gains are stored in Q4.8 format.
header.type should be set to one of either MALI_C55_PARAM_BLOCK_AWB_GAINS or
MALI_C55_PARAM_BLOCK_AWB_GAINS_AEXP from mali_c55_param_block_type.
enum mali_c55_params_awb_tap_points #
Tap points for the AWB statistics
Constants
MALI_C55_AWB_STATS_TAP_PF: Immediately after the Purple Fringe blockMALI_C55_AWB_STATS_TAP_CNR: Immediately after the CNR block
struct mali_c55_params_awb_config #
Stats settings for auto-white balance
Definition
;
Members
header: The Mali-C55 parameters block headertap_point: The tap point from enum mali_c55_params_awb_tap_pointsstats_mode: AWB statistics collection mode, seemali_c55_awb_stats_modewhite_level: Upper pixel intensity (I.E. raw pixel values) limitblack_level: Lower pixel intensity (I.E. raw pixel values) limitcr_max: Maximum R/G ratio (Q4.8 format)cr_min: Minimum R/G ratio (Q4.8 format)cb_max: Maximum B/G ratio (Q4.8 format)cb_min: Minimum B/G ratio (Q4.8 format)nodes_used_horiz: Number of active zones horizontally [0..15]nodes_used_vert: Number of active zones vertically [0..15]cr_high: R/G ratio trim high (Q4.8 format)cr_low: R/G ratio trim low (Q4.8 format)cb_high: B/G ratio trim high (Q4.8 format)cb_low: B/G ratio trim low (Q4.8 format)
Description
This struct allows the configuration of the statistics generated for auto white balance. Pixel intensity limits can be set to exclude overly bright or dark regions of an image from the statistics entirely. Colour ratio minima and maxima can be set to discount pixels who's ratios fall outside the defined boundaries; there are two sets of registers to do this - the "min/max" ratios which bound a region and the "high/low" ratios which further trim the upper and lower ratios. For example with the boundaries configured as follows, only pixels whos colour ratios falls into the region marked "A" would be counted:
cr_high
2.0 | |
| cb_max --> _________________________v_____
1.8 | | \ |
| | \ |
1.6 | | \ |
| | \ |
c 1.4 | cb_low -->|\ A \|<-- cb_high
b | | \ |
1.2 | | \ |
r | | \ |
a 1.0 | cb_min --> |____\_________________________|
t | ^ ^ ^
i 0.8 | | | |
o | cr_min | cr_max
s 0.6 | |
| cr_low
0.4 |
|
0.2 |
|
0.0 |_______________________________________________________________
0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0
cr ratios
header.type should be set to MALI_C55_PARAM_BLOCK_AWB_CONFIG from
mali_c55_param_block_type for this block.
struct mali_c55_params_mesh_shading_config #
Mesh shading configuration
Definition
;
Members
header: The Mali-C55 parameters block headermesh_show: Output the mesh data rather than image datamesh_scale: Set the precision and maximum gain range of mesh shading- 0 = 0-2x gain
- 1 = 0-4x gain
- 2 = 0-8x gain
- 3 = 0-16x gain
- 4 = 1-2x gain
- 5 = 1-3x gain
- 6 = 1-5x gain
- 7 = 1-9x gain
mesh_page_r: Mesh page select for red colour plane [0..2]mesh_page_g: Mesh page select for green colour plane [0..2]mesh_page_b: Mesh page select for blue colour plane [0..2]mesh_width: Number of horizontal nodes minus 1 [15,31]mesh_height: Number of vertical nodes minus 1 [15,31]mesh: Mesh shading correction tables
Description
The mesh shading correction module allows programming a separate table of either 16x16 or 32x32 node coefficients for 3 different light sources. The final correction coefficients applied are computed by blending the coefficients from two tables together.
A page of 1024 32-bit integers is associated to each colour channel, with pages stored consecutively in memory. Each 32-bit integer packs 3 8-bit correction coefficients for a single node, one for each of the three light sources. The 8 most significant bits are unused. The following table describes the layout:
+----------- Page (Colour Plane) 0 -------------+
| @mesh[i] | Mesh Point | Bits | Light Source |
+-----------+------------+-------+--------------+
| 0 | 0,0 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
| 1 | 0,1 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
| ... | ... | ... | ... |
+-----------+------------+-------+--------------+
| 1023 | 31,31 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+----------- Page (Colour Plane) 1 -------------+
| @mesh[i] | Mesh Point | Bits | Light Source |
+-----------+------------+-------+--------------+
| 1024 | 0,0 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
| 1025 | 0,1 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
| ... | ... | ... | ... |
+-----------+------------+-------+--------------+
| 2047 | 31,31 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+----------- Page (Colour Plane) 2 -------------+
| @mesh[i] | Mesh Point | Bits | Light Source |
+-----------+------------+-------+--------------+
| 2048 | 0,0 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
| 2049 | 0,1 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
| ... | ... | ... | ... |
+-----------+------------+-------+--------------+
| 3071 | 31,31 | 16,23 | LS2 |
| | | 08-15 | LS1 |
| | | 00-07 | LS0 |
+-----------+------------+-------+--------------+
The mesh_scale member determines the precision and minimum and maximum gain. For example if mesh_scale is 0 and therefore selects 0 - 2x gain, a value of 0 in a coefficient means 0.0 gain, a value of 128 means 1.0 gain and 255 means 2.0 gain.
header.type should be set to MALI_C55_PARAM_MESH_SHADING_CONFIG from
mali_c55_param_block_type for this block.
struct mali_c55_params_mesh_shading_selection #
Mesh table selection
Definition
;
Members
header: The Mali-C55 parameters block headermesh_alpha_bank_r: Red mesh table select (cenum mali_c55_params_mesh_alpha_bank)mesh_alpha_bank_g: Green mesh table select (cenum mali_c55_params_mesh_alpha_bank)mesh_alpha_bank_b: Blue mesh table select (cenum mali_c55_params_mesh_alpha_bank)mesh_alpha_r: Blend coefficient for R [0..255]mesh_alpha_g: Blend coefficient for G [0..255]mesh_alpha_b: Blend coefficient for B [0..255]mesh_strength: Mesh strength in Q4.12 format [0..4096]
Description
The module computes the final correction coefficients by blending the ones from two light source tables, which are selected (independently for each colour channel) by the mesh_alpha_bank_r/g/b fields.
The final blended coefficients for each node are calculated using the following equation:
Final coefficient = (a * LS\ b\ + (256 - a) * LS\ a) / 256
Where a is the mesh_alpha_r/g/b value, and LS\ a\ and LS\ b
are the node cofficients for the two tables selected by the
mesh_alpha_bank_r/g/b value.
The scale of the applied correction may also be controlled by tuning the mesh_strength member. This is a modifier to the final coefficients which can be used to globally reduce the gains applied.
header.type should be set to MALI_C55_PARAM_MESH_SHADING_SELECTION from
mali_c55_param_block_type for this block.
MALI_C55_PARAMS_MAX_SIZE #
Maximum size of all Mali C55 Parameters
Description
Though the parameters for the Mali-C55 are passed as optional blocks, the driver still needs to know the absolute maximum size so that it can allocate a buffer sized appropriately to accommodate userspace attempting to set all possible parameters in a single frame.
Some structs are in this list multiple times. Where that's the case, it just
reflects the fact that the same struct can be used with multiple different
header types from mali_c55_param_block_type.
V4L2_META_FMT_C3ISP_STATS ('C3ST'), V4L2_META_FMT_C3ISP_PARAMS ('C3PM')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
3A Statistics #
The C3 ISP can collect different statistics over an input Bayer frame. Those statistics are obtained from the "c3-isp-stats" metadata capture video nodes, using the v4l2_meta_format interface. They are formatted as described by the c3_isp_stats_info structure.
The statistics collected are Auto-white balance, Auto-exposure and Auto-focus information.
Configuration Parameters #
The configuration parameters are passed to the c3-isp-params metadata output video node, using the v4l2_meta_format interface. Rather than a single struct containing sub-structs for each configurable area of the ISP, parameters for the C3-ISP are defined as distinct structs or "blocks" which may be added to the data member of c3_isp_params_cfg. Userspace is responsible for populating the data member with the blocks that need to be configured by the driver, but need not populate it with all the blocks, or indeed with any at all if there are no configuration changes to make. Populated blocks must be consecutive in the buffer. To assist both userspace and the driver in identifying the blocks each block-specific struct embeds c3_isp_params_block_header as its first member and userspace must populate the type member with a value from c3_isp_params_block_type. Once the blocks have been populated into the data buffer, the combined size of all populated blocks shall be set in the data_size member of c3_isp_params_cfg. For example:
struct c3_isp_params_cfg *params =
buffer;
params->version = C3_ISP_PARAM_BUFFER_V0;
params->data_size = 0;
void *data = params->data;
struct c3_isp_params_awb_gains *gains =
data;
gains->header.type = C3_ISP_PARAMS_BLOCK_AWB_GAINS;
gains->header.flags = C3_ISP_PARAMS_BLOCK_FL_ENABLE;
gains->header.size = sizeof;
gains->gr_gain = 256;
gains->r_gain = 256;
gains->b_gain = 256;
gains->gb_gain = 256;
data += sizeof;
params->data_size += sizeof;
struct c3_isp_params_awb_config *awb_cfg =
data;
awb_cfg->header.type = C3_ISP_PARAMS_BLOCK_AWB_CONFIG;
awb_cfg->header.flags = C3_ISP_PARAMS_BLOCK_FL_ENABLE;
awb_cfg->header.size = sizeof;
awb_cfg->tap_point = C3_ISP_AWB_STATS_TAP_BEFORE_WB;
awb_cfg->satur = 1;
awb_cfg->horiz_zones_num = 32;
awb_cfg->vert_zones_num = 24;
params->data_size += sizeof;
Amlogic C3 ISP uAPI data types #
struct c3_isp_awb_zone_stats #
AWB statistics of a zone
Definition
;
Members
rg: the ratio of R / G in a zonebg: the ratio of B / G in a zonepixel_sum: the total number of pixels used in a zone
Description
AWB zone stats is aligned with 8 bytes
struct c3_isp_awb_stats #
Auto white balance statistics information.
Definition
;
Members
stats: array of auto white balance statistics
Description
AWB statistical information of all zones.
struct c3_isp_ae_zone_stats #
AE statistics of a zone
Definition
;
Members
hist0: the global normalized pixel count for bin 0hist1: the global normalized pixel count for bin 1hist3: the global normalized pixel count for bin 3hist4: the global normalized pixel count for bin 4
Description
AE zone stats is aligned with 8 bytes. This is a 5-bin histogram and the total sum is normalized to 0xffff. So hist2 = 0xffff - (hist0 + hist1 + hist3 + hist4)
struct c3_isp_ae_stats #
Exposure statistics information
Definition
;
Members
stats: array of auto exposure block statisticsreserved: undefined buffer spacehist: a 1024-bin histogram for the entire image
Description
AE statistical information consists of all blocks information and a 1024-bin histogram.
struct c3_isp_af_zone_stats #
AF statistics of a zone
Definition
;
Members
i2_mat: the mantissa of zonal squared image pixel sumi4_mat: the mantissa of zonal quartic image pixel sume4_mat: the mantissa of zonal multi-directional quartic edge sume4_exp: the exponent of zonal multi-directional quartic edge sumi2_exp: the exponent of zonal squared image pixel sumi4_exp: the exponent of zonal quartic image pixel sum
Description
AF zone stats is aligned with 8 bytes. The zonal accumulated contrast metrics are stored in floating point format with 16 bits mantissa and 5 or 6 bits exponent. Apart from contrast metrics we accumulate squared image and quartic image data over the zone.
struct c3_isp_af_stats #
Auto Focus statistics information
Definition
;
Members
stats: array of auto focus block statisticsreserved: undefined buffer space
Description
AF statistical information of each zone
struct c3_isp_stats_info #
V4L2_META_FMT_C3ISP_STATS
Definition
;
Members
awb: auto white balance statsae: auto exposure statsaf: auto focus stats
Description
Contains ISP statistics
enum c3_isp_params_buffer_version #
C3 ISP parameters block versioning
Constants
C3_ISP_PARAMS_BUFFER_V0: First version of C3 ISP parameters block
enum c3_isp_params_block_type #
Enumeration of C3 ISP parameter blocks
Constants
C3_ISP_PARAMS_BLOCK_AWB_GAINS: White balance gainsC3_ISP_PARAMS_BLOCK_AWB_CONFIG: AWB statistic format configuration for all blocks that control how stats are generatedC3_ISP_PARAMS_BLOCK_AE_CONFIG: AE statistic format configuration for all blocks that control how stats are generatedC3_ISP_PARAMS_BLOCK_AF_CONFIG: AF statistic format configuration for all blocks that control how stats are generatedC3_ISP_PARAMS_BLOCK_PST_GAMMA: post gamma parametersC3_ISP_PARAMS_BLOCK_CCM: Color correction matrix parametersC3_ISP_PARAMS_BLOCK_CSC: Color space conversion parametersC3_ISP_PARAMS_BLOCK_BLC: Black level correction parametersC3_ISP_PARAMS_BLOCK_SENTINEL: First non-valid block index
Description
Each block configures a specific processing block of the C3 ISP. The block type allows the driver to correctly interpret the parameters block data.
c3_isp_params_block_header #
c3_isp_params_block_header
C3 ISP parameter block header
Description
This structure represents the common part of all the ISP configuration
blocks and is identical to v4l2_isp_params_block_header.
The type field is one of the values enumerated by
c3_isp_params_block_type and specifies how the data should be
interpreted by the driver.
The flags field is a bitmask of per-block flags C3_ISP_PARAMS_FL_*.
struct c3_isp_params_awb_gains #
Gains for auto-white balance
Definition
;
Members
header: The C3 ISP parameters block headergr_gain: Multiplier for Gr channel (Q4.8 format)r_gain: Multiplier for R channel (Q4.8 format)b_gain: Multiplier for B channel (Q4.8 format)gb_gain: Multiplier for Gb channel (Q4.8 format)
Description
This struct allows users to configure the gains for white balance. There are four gain settings corresponding to each colour channel in the bayer domain. All of the gains are stored in Q4.8 format.
header.type should be set to C3_ISP_PARAMS_BLOCK_AWB_GAINS
from c3_isp_params_block_type
enum c3_isp_params_awb_tap_points #
Tap points for the AWB statistics
Constants
C3_ISP_AWB_STATS_TAP_OFE: immediately after the optical frontend blockC3_ISP_AWB_STATS_TAP_GE: immediately after the green equal blockC3_ISP_AWB_STATS_TAP_BEFORE_WB: immediately before the white balance blockC3_ISP_AWB_STATS_TAP_AFTER_WB: immediately after the white balance block
struct c3_isp_params_awb_config #
Stats settings for auto-white balance
Definition
;
Members
header: the C3 ISP parameters block headertap_point: the tap point from enum c3_isp_params_awb_tap_pointsatur_vald: AWB statistic over saturation control value: 0: disable, 1: enablehoriz_zones_num: active number of hotizontal zones [0..32]vert_zones_num: active number of vertical zones [0..24]rg_min: minimum R/G ratio (Q4.8 format)rg_max: maximum R/G ratio (Q4.8 format)bg_min: minimum B/G ratio (Q4.8 format)bg_max: maximum B/G ratio (Q4.8 format)rg_low: R/G ratio trim low (Q4.8 format)rg_high: R/G ratio trim hight (Q4.8 format)bg_low: B/G ratio trim low (Q4.8 format)bg_high: B/G ratio trim high (Q4.8 format)zone_weight: array of weights for AWB statistics zones [0..15]horiz_coord: the horizontal coordinate of points on the diagonal [0..2888]vert_coord: the vertical coordinate of points on the diagonal [0..2240]
Description
This struct allows the configuration of the statistics generated for auto white balance.
header.type should be set to C3_ISP_PARAMS_BLOCK_AWB_CONFIG
from c3_isp_params_block_type
enum c3_isp_params_ae_tap_points #
Tap points for the AE statistics
Constants
C3_ISP_AE_STATS_TAP_GE: immediately after the green equal blockC3_ISP_AE_STATS_TAP_MLS: immediately after the mesh lens shading block
struct c3_isp_params_ae_config #
Stats settings for auto-exposure
Definition
;
Members
header: the C3 ISP parameters block headertap_point: the tap point from enum c3_isp_params_ae_tap_pointhoriz_zones_num: active number of horizontal zones [0..17]vert_zones_num: active number of vertical zones [0..15]zone_weight: array of weights for AE statistics zones [0..15]horiz_coord: the horizontal coordinate of points on the diagonal [0..2888]vert_coord: the vertical coordinate of points on the diagonal [0..2240]reserved: applications must zero this array
Description
This struct allows the configuration of the statistics generated for auto exposure.
header.type should be set to C3_ISP_PARAMS_BLOCK_AE_CONFIG
from c3_isp_params_block_type
enum c3_isp_params_af_tap_points #
Tap points for the AF statistics
Constants
C3_ISP_AF_STATS_TAP_SNR: immediately after the spatial noise reduce blockC3_ISP_AF_STATS_TAP_DMS: immediately after the demosaic block
struct c3_isp_params_af_config #
Stats settings for auto-focus
Definition
;
Members
header: the C3 ISP parameters block headertap_point: the tap point from enum c3_isp_params_af_tap_pointhoriz_zones_num: active number of hotizontal zones [0..17]vert_zones_num: active number of vertical zones [0..15]reserved: applications must zero this arrayhoriz_coord: the horizontal coordinate of points on the diagonal [0..2888]vert_coord: the vertical coordinate of points on the diagonal [0..2240]
Description
This struct allows the configuration of the statistics generated for auto focus.
header.type should be set to C3_ISP_PARAMS_BLOCK_AF_CONFIG
from c3_isp_params_block_type
struct c3_isp_params_pst_gamma #
Post gamma configuration
Definition
;
Members
header: the C3 ISP parameters block headerlut: lookup table for P-Stitch gamma [0..1023]reserved: applications must zero this array
Description
This struct allows the configuration of the look up table for post gamma. The gamma curve consists of 129 points, so need to set lut[129].
header.type should be set to C3_ISP_PARAMS_BLOCK_PST_GAMMA
from c3_isp_params_block_type
struct c3_isp_params_ccm #
ISP CCM configuration
Definition
;
Members
header: the C3 ISP parameters block headermatrix: a 3 x 3 matrix used for color correction, the value of matrix[x][y] is orig_value x 256. [-4096..4095]reserved: applications must zero this array
Description
This struct allows the configuration of the matrix for color correction. The matrix consists of 3 x 3 points, so need to set matrix[3][3].
header.type should be set to C3_ISP_PARAMS_BLOCK_CCM
from c3_isp_params_block_type
struct c3_isp_params_csc #
ISP Color Space Conversion configuration
Definition
;
Members
header: the C3 ISP parameters block headermatrix: a 3x3 matrix used for the color space conversion, the value of matrix[x][y] is orig_value x 256. [-4096..4095]reserved: applications must zero this array
Description
This struct allows the configuration of the matrix for color space conversion. The matrix consists of 3 x 3 points, so need to set matrix[3][3].
header.type should be set to C3_ISP_PARAMS_BLOCK_CSC
from c3_isp_params_block_type
struct c3_isp_params_blc #
ISP Black Level Correction configuration
Definition
;
Members
header: the C3 ISP parameters block headergr_ofst: Gr blc offset (Q4.12 format)r_ofst: R blc offset (Q4.12 format)b_ofst: B blc offset (Q4.12 format)gb_ofst: Gb blc offset(Q4.12 format)
Description
This struct allows the configuration of the block level offset for each color channel.
header.type should be set to C3_ISP_PARAMS_BLOCK_BLC
from c3_isp_params_block_type
C3_ISP_PARAMS_MAX_SIZE #
Maximum size of all C3 ISP Parameters
Description
Though the parameters for the C3 ISP are passed as optional blocks, the driver still needs to know the absolute maximum size so that it can allocate a buffer sized appropriately to accommodate userspace attempting to set all possible parameters in a single frame.
struct c3_isp_params_cfg #
C3 ISP configuration parameters
Definition
;
Members
version: The C3 ISP parameters buffer versiondata_size: The C3 ISP configuration data effective size, excluding this headerdata: The C3 ISP configuration blocks data
Description
This is the driver-specific implementation of
v4l2_isp_params_buffer.
Currently only C3_ISP_PARAM_BUFFER_V0 is supported.
The expected memory layout of the parameters buffer is:
+-------------------- struct c3_isp_params_cfg ---- ------------------+
| version = C3_ISP_PARAM_BUFFER_V0; |
| data_size = sizeof(struct c3_isp_params_awb_gains) + |
| sizeof(struct c3_isp_params_awb_config); |
| +------------------------- data ---------------------------------+ |
| | +------------ struct c3_isp_params_awb_gains) ------------------+ |
| | | +--------- struct c3_isp_params_block_header header -----+ | | |
| | | | type = C3_ISP_PARAMS_BLOCK_AWB_GAINS; | | | |
| | | | flags = C3_ISP_PARAMS_BLOCK_FL_NONE; | | | |
| | | | size = sizeof(struct c3_isp_params_awb_gains); | | | |
| | | +---------------------------------------------------------+ | | |
| | | gr_gain = ...; | | |
| | | r_gain = ...; | | |
| | | b_gain = ...; | | |
| | | gb_gain = ...; | | |
| | +------------------ struct c3_isp_params_awb_config ----------+ | |
| | | +---------- struct c3_isp_param_block_header header ------+ | | |
| | | | type = C3_ISP_PARAMS_BLOCK_AWB_CONFIG; | | | |
| | | | flags = C3_ISP_PARAMS_BLOCK_FL_NONE; | | | |
| | | | size = sizeof(struct c3_isp_params_awb_config) | | | |
| | | +---------------------------------------------------------+ | | |
| | | tap_point = ...; | | |
| | | satur_vald = ...; | | |
| | | horiz_zones_num = ...; | | |
| | | vert_zones_num = ...; | | |
| | +-------------------------------------------------------------+ | |
| +-----------------------------------------------------------------+ |
+---------------------------------------------------------------------+
V4L2_META_FMT_D4XX ('D4XX')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Intel D4xx UVC Cameras Metadata
Description #
Intel D4xx (D435, D455 and others) cameras include per-frame metadata in their UVC payload headers, following the Microsoft(R) UVC extension proposal [1]. That means, that the private D4XX metadata, following the standard UVC header, is organised in blocks. D4XX cameras implement several standard block types, proposed by Microsoft, and several proprietary ones. Supported standard metadata types are MetadataId_CaptureStats (ID 3), MetadataId_CameraExtrinsics (ID 4), and MetadataId_CameraIntrinsics (ID 5). For their description see [1]. This document describes proprietary metadata types, used by D4xx cameras.
V4L2_META_FMT_D4XX buffers follow the metadata buffer layout of V4L2_META_FMT_UVC with the only difference, that it also includes proprietary payload header data. D4xx cameras use bulk transfers and only send one payload per frame, therefore their headers cannot be larger than 255 bytes.
This document implements Intel Configuration version 3 [9].
Below are proprietary Microsoft style metadata types, used by D4xx cameras, where all fields are in little endian order:
|
Field |
Description |
|---|---|
|
Depth Control |
|
|
__u32 ID |
0x80000000 |
|
__u32 Size |
Size in bytes, include ID (all protocol versions: 60) |
|
__u32 Version |
Version of this structure. The documentation herein covers versions 1, 2 and 3. The version number will be incremented when new fields are added. |
|
__u32 Flags |
A bitmask of flags: see [2] below |
|
__u32 Gain |
Gain value in internal units, same as the V4L2_CID_GAIN control, used to capture the frame |
|
__u32 Exposure |
Exposure time (in microseconds) used to capture the frame |
|
__u32 Laser power |
Power of the laser LED 0-360, used for depth measurement |
|
__u32 AE mode |
0: manual; 1: automatic exposure |
|
__u32 Exposure priority |
Exposure priority value: 0 - constant frame rate |
|
__u32 AE ROI left |
Left border of the AE Region of Interest (all ROI values are in pixels and lie between 0 and maximum width or height respectively) |
|
__u32 AE ROI right |
Right border of the AE Region of Interest |
|
__u32 AE ROI top |
Top border of the AE Region of Interest |
|
__u32 AE ROI bottom |
Bottom border of the AE Region of Interest |
|
__u32 Preset |
Preset selector value, default: 0, unless changed by the user |
|
__u8 Emitter mode (v3 only) (__u32 Laser mode for v1) [8] |
0: off, 1: on, same as __u32 Laser mode for v1 |
|
__u8 RFU byte (v3 only) |
Spare byte for future use |
|
__u16 LED Power (v3 only) |
Led power value 0-360 (F416 SKU) |
|
Capture Timing |
|
|
__u32 ID |
0x80000001 |
|
__u32 Size |
Size in bytes, include ID (all protocol versions: 40) |
|
__u32 Version |
Version of this structure. The documentation herein corresponds to version xxx. The version number will be incremented when new fields are added. |
|
__u32 Flags |
A bitmask of flags: see [3] below |
|
__u32 Frame counter |
Monotonically increasing counter |
|
__u32 Optical time |
Time in microseconds from the beginning of a frame till its middle |
|
__u32 Readout time |
Time, used to read out a frame in microseconds |
|
__u32 Exposure time |
Frame exposure time in microseconds |
|
__u32 Frame interval |
In microseconds = 1000000 / framerate |
|
__u32 Pipe latency |
Time in microseconds from start of frame to data in USB buffer |
|
Configuration |
|
|
__u32 ID |
0x80000002 |
|
__u32 Size |
Size in bytes, include ID (v1:36, v3:40) |
|
__u32 Version |
Version of this structure. The documentation herein corresponds to version xxx. The version number will be incremented when new fields are added. |
|
__u32 Flags |
A bitmask of flags: see [4] below |
|
__u8 Hardware type |
Camera hardware version [5] |
|
__u8 SKU ID |
Camera hardware configuration [6] |
|
__u32 Cookie |
Internal synchronisation |
|
__u16 Format |
Image format code [7] |
|
__u16 Width |
Width in pixels |
|
__u16 Height |
Height in pixels |
|
__u16 Framerate |
Requested frame rate per second |
|
__u16 Trigger |
Byte 0: bit 0: depth and RGB are synchronised, bit 1: external trigger |
|
__u16 Calibration count (v3 only) |
Calibration counter, see [4] below |
|
__u8 GPIO input data (v3 only) |
GPIO readout, see [4] below (Supported from FW 5.12.7.0) |
|
__u32 Sub-preset info (v3 only) |
Sub-preset choice information, see [4] below |
|
__u8 reserved (v3 only) |
RFU byte. |
[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/stream/uvc-extensions-1-5
[2] Depth Control flags specify which fields are valid:
0x00000001 Gain
0x00000002 Exposure
0x00000004 Laser power
0x00000008 AE mode
0x00000010 Exposure priority
0x00000020 AE ROI
0x00000040 Preset
0x00000080 Emitter mode
0x00000100 LED Power
[3] Capture Timing flags specify which fields are valid:
0x00000001 Frame counter
0x00000002 Optical time
0x00000004 Readout time
0x00000008 Exposure time
0x00000010 Frame interval
0x00000020 Pipe latency
[4] Configuration flags specify which fields are valid:
0x00000001 Hardware type
0x00000002 SKU ID
0x00000004 Cookie
0x00000008 Format
0x00000010 Width
0x00000020 Height
0x00000040 Framerate
0x00000080 Trigger
0x00000100 Cal count
0x00000200 GPIO Input Data
0x00000400 Sub-preset Info
[5] Camera model:
0 DS5
1 IVCAM2
[6] 8-bit camera hardware configuration bitfield:
[1:0] depthCamera
00: no depth
01: standard depth
10: wide depth
11: reserved
[2] depthIsActive - has a laser projector
[3] RGB presence
[4] Inertial Measurement Unit (IMU) presence
[5] projectorType
0: HPTG
1: Princeton
[6] 0: a projector, 1: an LED
[7] reserved
[7] Image format codes per video streaming interface:
Depth:
1 Z16
2 Z
Left sensor:
1 Y8
2 UYVY
3 R8L8
4 Calibration
5 W10
Fish Eye sensor:
1 RAW8
[8] The "Laser mode" has been replaced in version 3 by three different fields. "Laser" has been renamed to "Emitter" as there are multiple technologies for camera projectors. As we have another field for "Laser Power" we introduced "LED Power" for extra emitter.
-
The "Laser mode" __u32 fields has been split into: ::
1 __u8 Emitter mode 2 __u8 RFU byte 3 __u16 LED Power
This is a change between versions 1 and 3. All versions 1, 2 and 3 are backward compatible with the same data format and they are supported. See [2] for which attributes are valid.
[9] LibRealSense SDK metadata source: https://github.com/IntelRealSense/librealsense/blob/master/src/metadata.h
V4L2_META_FMT_GENERIC_8 ('MET8'), V4L2_META_FMT_GENERIC_CSI2_10 ('MC1A'), V4L2_META_FMT_GENERIC_CSI2_12 ('MC1C'), V4L2_META_FMT_GENERIC_CSI2_14 ('MC1E'), V4L2_META_FMT_GENERIC_CSI2_16 ('MC1G'), V4L2_META_FMT_GENERIC_CSI2_20 ('MC1K'), V4L2_META_FMT_GENERIC_CSI2_24 ('MC1O')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Generic line-based metadata formats
Description #
These generic line-based metadata formats define the memory layout of the data without defining the format or meaning of the metadata itself.
V4L2_META_FMT_GENERIC_8 #
The V4L2_META_FMT_GENERIC_8 format is a plain 8-bit metadata format. This format is used on CSI-2 for 8 bits per Data Unit.
Additionally it is used for 16 bits per Data Unit when two bytes of metadata are packed into one 16-bit Data Unit. Otherwise the 16 bits per pixel dataformat is V4L2_META_FMT_GENERIC_CSI2_16.
Byte Order Of V4L2_META_FMT_GENERIC_8. Each cell is one byte. "M" denotes a byte of metadata.
|
start + 0: |
M00 |
M10 |
M20 |
M30 |
|
start + 4: |
M01 |
M11 |
M21 |
M31 |
V4L2_META_FMT_GENERIC_CSI2_10 #
V4L2_META_FMT_GENERIC_CSI2_10 contains 8-bit generic metadata packed in 10-bit Data Units, with one padding byte after every four bytes of metadata. This format is typically used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_10 and the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of the data is defined in the MIPI CCS specification.
This format is also used in conjunction with 20 bits per Data Unit formats that pack two bytes of metadata into one Data Unit. Otherwise the 20 bits per pixel dataformat is V4L2_META_FMT_GENERIC_CSI2_20.
This format is little endian.
Byte Order Of V4L2_META_FMT_GENERIC_CSI2_10. Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
|
start + 0: |
M00 |
M10 |
M20 |
M30 |
x |
|
start + 5: |
M01 |
M11 |
M21 |
M31 |
x |
V4L2_META_FMT_GENERIC_CSI2_12 #
V4L2_META_FMT_GENERIC_CSI2_12 contains 8-bit generic metadata packed in 12-bit Data Units, with one padding byte after every two bytes of metadata. This format is typically used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_12 and the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of the data is defined in the MIPI CCS specification.
This format is also used in conjunction with 24 bits per Data Unit formats that pack two bytes of metadata into one Data Unit. Otherwise the 24 bits per pixel dataformat is V4L2_META_FMT_GENERIC_CSI2_24.
This format is little endian.
Byte Order Of V4L2_META_FMT_GENERIC_CSI2_12. Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
|
start + 0: |
M00 |
M10 |
x |
M20 |
M30 |
x |
|
start + 6: |
M01 |
M11 |
x |
M21 |
M31 |
x |
V4L2_META_FMT_GENERIC_CSI2_14 #
V4L2_META_FMT_GENERIC_CSI2_14 contains 8-bit generic metadata packed in 14-bit Data Units, with three padding bytes after every four bytes of metadata. This format is typically used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_14 and the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of the data is defined in the MIPI CCS specification.
This format is little endian.
Byte Order Of V4L2_META_FMT_GENERIC_CSI2_14. Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
|
start + 0: |
M00 |
M10 |
M20 |
M30 |
x |
x |
x |
|
start + 7: |
M01 |
M11 |
M21 |
M31 |
x |
x |
x |
V4L2_META_FMT_GENERIC_CSI2_16 #
V4L2_META_FMT_GENERIC_CSI2_16 contains 8-bit generic metadata packed in 16-bit Data Units, with one padding byte after every byte of metadata. This format is typically used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_16 and the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of the data is defined in the MIPI CCS specification.
Some devices support more efficient packing of metadata in conjunction with 16-bit image data. In that case the dataformat is V4L2_META_FMT_GENERIC_8.
This format is little endian.
Byte Order Of V4L2_META_FMT_GENERIC_CSI2_16. Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
|
start + 0: |
M00 |
x |
M10 |
x |
M20 |
x |
M30 |
x |
|
start + 8: |
M01 |
x |
M11 |
x |
M21 |
x |
M31 |
x |
V4L2_META_FMT_GENERIC_CSI2_20 #
V4L2_META_FMT_GENERIC_CSI2_20 contains 8-bit generic metadata packed in 20-bit Data Units, with alternating one or two padding bytes after every byte of metadata. This format is typically used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_20 and the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of the data is defined in the MIPI CCS specification.
Some devices support more efficient packing of metadata in conjunction with 16-bit image data. In that case the dataformat is V4L2_META_FMT_GENERIC_CSI2_10.
This format is little endian.
Byte Order Of V4L2_META_FMT_GENERIC_CSI2_20. Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
|
start + 0: |
M00 |
x |
M10 |
x |
x |
M20 |
x |
M30 |
x |
x |
|
start + 10: |
M01 |
x |
M11 |
x |
x |
M21 |
x |
M31 |
x |
x |
V4L2_META_FMT_GENERIC_CSI2_24 #
V4L2_META_FMT_GENERIC_CSI2_24 contains 8-bit generic metadata packed in 24-bit Data Units, with two padding bytes after every byte of metadata. This format is typically used by CSI-2 receivers with a source that transmits MEDIA_BUS_FMT_META_24 and the CSI-2 receiver writes the received data to memory as-is.
The packing of the data follows the MIPI CSI-2 specification and the padding of the data is defined in the MIPI CCS specification.
Some devices support more efficient packing of metadata in conjunction with 16-bit image data. In that case the dataformat is V4L2_META_FMT_GENERIC_CSI2_12.
This format is little endian.
Byte Order Of V4L2_META_FMT_GENERIC_CSI2_24. Each cell is one byte. "M" denotes a byte of metadata and "x" a byte of padding.
|
start + 0: |
M00 |
x |
x |
M10 |
x |
x |
M20 |
x |
x |
M30 |
x |
x |
|
start + 12: |
M01 |
x |
x |
M11 |
x |
x |
M21 |
x |
x |
M31 |
x |
x |
V4L2_META_FMT_IPU3_PARAMS ('ip3p'), V4L2_META_FMT_IPU3_3A ('ip3s')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
3A statistics #
The IPU3 ImgU 3A statistics accelerators collect different statistics over an input Bayer frame. Those statistics are obtained from the "ipu3-imgu [01] 3a stat" metadata capture video nodes, using the v4l2_meta_format interface. They are formatted as described by the ipu3_uapi_stats_3a structure.
The statistics collected are AWB (Auto-white balance) RGBS (Red, Green, Blue and Saturation measure) cells, AWB filter response, AF (Auto-focus) filter response, and AE (Auto-exposure) histogram.
The struct ipu3_uapi_4a_config saves all configurable parameters.
;
Pipeline parameters #
The pipeline parameters are passed to the "ipu3-imgu [01] parameters" metadata output video nodes, using the v4l2_meta_format interface. They are formatted as described by the ipu3_uapi_params structure.
Both 3A statistics and pipeline parameters described here are closely tied to the underlying camera sub-system (CSS) APIs. They are usually consumed and produced by dedicated user space libraries that comprise the important tuning tools, thus freeing the developers from being bothered with the low level hardware and algorithm details.
;
Intel IPU3 ImgU uAPI data types #
struct ipu3_uapi_grid_config #
Grid plane config
Definition
;
Members
width: Grid horizontal dimensions, in number of grid blocks(cells). For AWB, the range is (16, 80). For AF/AE, the range is (16, 32).height: Grid vertical dimensions, in number of grid cells. For AWB, the range is (16, 60). For AF/AE, the range is (16, 24).block_width_log2: Log2 of the width of each cell in pixels. For AWB, the range is [3, 6]. For AF/AE, the range is [3, 7].block_height_log2: Log2 of the height of each cell in pixels. For AWB, the range is [3, 6]. For AF/AE, the range is [3, 7].height_per_slice: The number of blocks in vertical axis per slice. Default 2.x_start: X value of top left corner of Region of Interest(ROI).y_start: Y value of top left corner of ROIx_end: X value of bottom right corner of ROIy_end: Y value of bottom right corner of ROI
Description
Due to the size of total amount of collected data, most statistics create a grid-based output, and the data is then divided into "slices".
struct ipu3_uapi_awb_set_item #
Memory layout for each cell in AWB
Definition
;
Members
Gr_avg: Green average for red lines in the cell.R_avg: Red average in the cell.B_avg: Blue average in the cell.Gb_avg: Green average for blue lines in the cell.sat_ratio: Percentage of pixels over the thresholds specified in ipu3_uapi_awb_config_s, coded from 0 to 255.padding0: Unused byte for padding.padding1: Unused byte for padding.padding2: Unused byte for padding.
struct ipu3_uapi_awb_raw_buffer #
AWB raw buffer
Definition
;
Members
meta_data: buffer to hold auto white balance meta data which is the average values for each color channel.
struct ipu3_uapi_awb_config_s #
AWB config
Definition
;
Members
rgbs_thr_gr: gr threshold value.rgbs_thr_r: Red threshold value.rgbs_thr_gb: gb threshold value.rgbs_thr_b: Blue threshold value.grid:ipu3_uapi_grid_config, the default grid resolution is 16x16 cells.
Description
The threshold is a saturation measure range [0, 8191], 8191 is default. Values over threshold may be optionally rejected for averaging.
struct ipu3_uapi_awb_config #
AWB config wrapper
Definition
;
Members
config: config for auto white balance as defined byipu3_uapi_awb_config_s
struct ipu3_uapi_ae_raw_buffer #
AE global weighted histogram
Definition
;
Members
vals: Sum of IPU3_UAPI_AE_COLORS in cell
Description
Each histogram contains IPU3_UAPI_AE_BINS bins. Each bin has 24 bit unsigned for counting the number of the pixel.
struct ipu3_uapi_ae_raw_buffer_aligned #
AE raw buffer
Definition
;
Members
buff:ipu3_uapi_ae_raw_bufferto hold full frame meta data.
struct ipu3_uapi_ae_grid_config #
AE weight grid
Definition
;
Members
width: Grid horizontal dimensions. Value: [16, 32], default 16.height: Grid vertical dimensions. Value: [16, 24], default 16.block_width_log2: Log2 of the width of the grid cell, value: [3, 7].block_height_log2: Log2 of the height of the grid cell, value: [3, 7]. default is 3 (cell size 8x8), 4 cell per grid.reserved0: reservedae_en: 0: does not write toipu3_uapi_ae_raw_buffer_alignedarray, 1: write normally.rst_hist_array: write 1 to trigger histogram array reset.done_rst_hist_array: flag for histogram array reset done.x_start: X value of top left corner of ROI, default 0.y_start: Y value of top left corner of ROI, default 0.x_end: X value of bottom right corner of ROIy_end: Y value of bottom right corner of ROI
Description
The AE block accumulates 4 global weighted histograms(R, G, B, Y) over
a defined ROI within the frame. The contribution of each pixel into the
histogram, defined by ipu3_uapi_ae_weight_elem LUT, is indexed by a grid.
struct ipu3_uapi_ae_weight_elem #
AE weights LUT
Definition
;
Members
cell0: weighted histogram grid value.cell1: weighted histogram grid value.cell2: weighted histogram grid value.cell3: weighted histogram grid value.cell4: weighted histogram grid value.cell5: weighted histogram grid value.cell6: weighted histogram grid value.cell7: weighted histogram grid value.
Description
Use weighted grid value to give a different contribution factor to each cell. Precision u4, range [0, 15].
struct ipu3_uapi_ae_ccm #
AE coefficients for WB and CCM
Definition
;
Members
gain_gr: WB gain factor for the gr channels. Default 256.gain_r: WB gain factor for the r channel. Default 256.gain_b: WB gain factor for the b channel. Default 256.gain_gb: WB gain factor for the gb channels. Default 256.mat: 4x4 matrix that transforms Bayer quad output from WB to RGB+Y.
Description
- Default: 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128, 0, 0, 0, 0, 128,
As part of the raw frame pre-process stage, the WB and color conversion need to be applied to expose the impact of these gain operations.
struct ipu3_uapi_ae_config #
AE config
Definition
;
Members
grid_cfg: config for auto exposure statistics grid. See structipu3_uapi_ae_grid_config, as Imgu did not support output auto exposure statistics, so user can ignore this configuration and use the RGB table in auto-whitebalance statistics instead.weights:IPU3_UAPI_AE_WEIGHTSis based on 32x24 blocks in the grid. Each grid cell has a corresponding value in weights LUT called grid value, global histogram is updated based on grid value and pixel value.ae_ccm: Color convert matrix pre-processing block.
Description
Calculate AE grid from image resolution, resample ae weights.
struct ipu3_uapi_af_filter_config #
AF 2D filter for contrast measurements
Definition
;
Members
y1_coeff_0: filter Y1, structure: 3x11, support both symmetry and anti-symmetry type. A12 is center, A1-A11 are neighbours. for analyzing low frequency content, used to calculate sum of gradients in x direction.y1_coeff_0.a1: filter1 coefficients A1, u8, default 0.y1_coeff_0.a2: filter1 coefficients A2, u8, default 0.y1_coeff_0.a3: filter1 coefficients A3, u8, default 0.y1_coeff_0.a4: filter1 coefficients A4, u8, default 0.y1_coeff_1: Structy1_coeff_1.a5: filter1 coefficients A5, u8, default 0.y1_coeff_1.a6: filter1 coefficients A6, u8, default 0.y1_coeff_1.a7: filter1 coefficients A7, u8, default 0.y1_coeff_1.a8: filter1 coefficients A8, u8, default 0.y1_coeff_2: Structy1_coeff_2.a9: filter1 coefficients A9, u8, default 0.y1_coeff_2.a10: filter1 coefficients A10, u8, default 0.y1_coeff_2.a11: filter1 coefficients A11, u8, default 0.y1_coeff_2.a12: filter1 coefficients A12, u8, default 128.y1_sign_vec: Each bit corresponds to one coefficient sign bit, 0: positive, 1: negative, default 0.y2_coeff_0: Y2, same structure as Y1. For analyzing high frequency content.y2_coeff_0.a1: filter2 coefficients A1, u8, default 0.y2_coeff_0.a2: filter2 coefficients A2, u8, default 0.y2_coeff_0.a3: filter2 coefficients A3, u8, default 0.y2_coeff_0.a4: filter2 coefficients A4, u8, default 0.y2_coeff_1: Structy2_coeff_1.a5: filter2 coefficients A5, u8, default 0.y2_coeff_1.a6: filter2 coefficients A6, u8, default 0.y2_coeff_1.a7: filter2 coefficients A7, u8, default 0.y2_coeff_1.a8: filter2 coefficients A8, u8, default 0.y2_coeff_2: Structy2_coeff_2.a9: filter1 coefficients A9, u8, default 0.y2_coeff_2.a10: filter1 coefficients A10, u8, default 0.y2_coeff_2.a11: filter1 coefficients A11, u8, default 0.y2_coeff_2.a12: filter1 coefficients A12, u8, default 128.y2_sign_vec: Each bit corresponds to one coefficient sign bit, 0: positive, 1: negative, default 0.y_calc: Pre-processing that converts Bayer quad to RGB+Y values to be used for building histogram. Range [0, 32], default 8.y_calc.y_gen_rate_gr: Contribution ratio Gr for Yy_calc.y_gen_rate_r: Contribution ratio R for Yy_calc.y_gen_rate_b: Contribution ratio B for Yy_calc.y_gen_rate_gb: Contribution ratio Gb for Ynf: The shift right value that should be applied during the Y1/Y2 filter to make sure the total memory needed is 2 bytes per grid cell.nf.reserved0: reservednf.y1_nf: Normalization factor for the convolution coeffs of y1, should be log2 of the sum of the abs values of the filter coeffs, default 7 (2^7 = 128).nf.reserved1: reservednf.y2_nf: Normalization factor for y2, should be log2 of the sum of the abs values of the filter coeffs.nf.reserved2: reserved
Description
Rule: y_gen_rate_gr + y_gen_rate_r + y_gen_rate_b + y_gen_rate_gb = 32 A single Y is calculated based on sum of Gr/R/B/Gb based on their contribution ratio.
struct ipu3_uapi_af_raw_buffer #
AF meta data
Definition
;
Members
y_table: Each color component will be convolved separately with filter1 and filter2 and the result will be summed out and averaged for each cell.
struct ipu3_uapi_af_config_s #
AF config
Definition
;
Members
filter_config: AF uses Y1 and Y2 filters as configured inipu3_uapi_af_filter_configpadding: paddingsgrid_cfg: Seeipu3_uapi_grid_config, default resolution 16x16. Use large grid size for large image and vice versa.
struct ipu3_uapi_awb_fr_raw_buffer #
AWB filter response meta data
Definition
;
Members
meta_data: Statistics output on the grid after convolving with 1D filter.
struct ipu3_uapi_awb_fr_config_s #
AWB filter response config
Definition
;
Members
grid_cfg: grid config, default 16x16.bayer_coeff: 1D Filter 1x11 center symmetry/anti-symmetry. coefficients defaults { 0, 0, 0, 0, 0, 128 }. Applied on whole image for each Bayer channel separately by a weighted sum of its 11x1 neighbors.reserved1: reservedbayer_sign: sign of filter coefficients, default 0.bayer_nf: normalization factor for the convolution coeffs, to make sure total memory needed is within pre-determined range. NF should be the log2 of the sum of the abs values of the filter coeffs, range [7, 14], default 7.reserved2: reserved
struct ipu3_uapi_4a_config #
4A config
Definition
;
Members
awb_config:ipu3_uapi_awb_config_s, default resolution 16x16ae_grd_config: auto exposure statisticsipu3_uapi_ae_grid_configpadding: paddingsaf_config: auto focus configipu3_uapi_af_config_sawb_fr_config:ipu3_uapi_awb_fr_config_s, default resolution 16x16
struct ipu3_uapi_bubble_info #
Bubble info for host side debugging
Definition
;
Members
num_of_stripes: A single frame is divided into several parts called stripes due to limitation on line buffer memory. The separation between the stripes is vertical. Each such stripe is processed as a single frame by the ISP pipe.padding: padding bytes.num_sets: number of sets.padding1: padding bytes.size_of_set: set size.padding2: padding bytes.bubble_size: is the amount of padding in the bubble expressed in "sets".padding3: padding bytes.
struct ipu3_uapi_ff_status #
Enable bits for each 3A fixed function
Definition
;
Members
awb_en: auto white balance enablepadding: padding configae_en: auto exposure enablepadding1: padding configaf_en: auto focus enablepadding2: padding configawb_fr_en: awb filter response enable bitpadding3: padding config
struct ipu3_uapi_stats_3a #
3A statistics
Definition
;
Members
awb_raw_buffer: auto white balance meta dataipu3_uapi_awb_raw_bufferae_raw_buffer: auto exposure raw dataipu3_uapi_ae_raw_buffer_alignedcurrent Imgu does not output the auto exposure statistics to ae_raw_buffer, the user such as 3A algorithm can use the RGB table inipu3_uapi_awb_raw_bufferto do auto-exposure.af_raw_buffer:ipu3_uapi_af_raw_bufferfor auto focus meta dataawb_fr_raw_buffer: value as specified byipu3_uapi_awb_fr_raw_bufferstats_4a_config: 4a statistics config as defined byipu3_uapi_4a_config.ae_join_buffers: 1 to use ae_raw_buffer.padding: padding configstats_3a_bubble_per_stripe: aipu3_uapi_stats_3a_bubble_info_per_stripestats_3a_status: 3a statistics status set inipu3_uapi_ff_status
struct ipu3_uapi_bnr_static_config_wb_gains_config #
White balance gains
Definition
;
Members
gr: white balance gain for Gr channel.r: white balance gain for R channel.b: white balance gain for B channel.gb: white balance gain for Gb channel.
Description
For BNR parameters WB gain factor for the three channels [Ggr, Ggb, Gb, Gr]. Their precision is U3.13 and the range is (0, 8) and the actual gain is Gx + 1, it is typically Gx = 1.
Pout = {Pin * (1 + Gx)}.
struct ipu3_uapi_bnr_static_config_wb_gains_thr_config #
Threshold config
Definition
;
Members
gr: white balance threshold gain for Gr channel.r: white balance threshold gain for R channel.b: white balance threshold gain for B channel.gb: white balance threshold gain for Gb channel.
Description
Defines the threshold that specifies how different a defect pixel can be from its neighbors.(used by dynamic defect pixel correction sub block) Precision u4.4 range [0, 8].
struct ipu3_uapi_bnr_static_config_thr_coeffs_config #
Noise model coefficients that controls noise threshold
Definition
;
Members
cf: Free coefficient for threshold calculation, range [0, 8191], default 0.reserved0: reservedcg: Gain coefficient for threshold calculation, [0, 31], default 8.ci: Intensity coefficient for threshold calculation. range [0, 0x1f] default 6. format: u3.2 (3 most significant bits represent whole number, 2 least significant bits represent the fractional part with each count representing 0.25) e.g. 6 in binary format is 00110, that translates to 1.5reserved1: reservedr_nf: Normalization shift value for r^2 calculation, range [12, 20] where r is a radius of pixel [row, col] from centor of sensor. default 14.
Description
Threshold used to distinguish between noise and details.
struct ipu3_uapi_bnr_static_config_thr_ctrl_shd_config #
Shading config
Definition
;
Members
gr: Coefficient defines lens shading gain approximation for gr channelr: Coefficient defines lens shading gain approximation for r channelb: Coefficient defines lens shading gain approximation for b channelgb: Coefficient defines lens shading gain approximation for gb channel
Description
Parameters for noise model (NM) adaptation of BNR due to shading correction. All above have precision of u3.3, default to 0.
struct ipu3_uapi_bnr_static_config_opt_center_config #
Optical center config
Definition
;
Members
x_reset: Reset value of X (col start - X center). Precision s12.0.reserved0: reservedy_reset: Reset value of Y (row start - Y center). Precision s12.0.reserved2: reserved
Description
Distance from corner to optical center for NM adaptation due to shading correction (should be calculated based on shading tables)
struct ipu3_uapi_bnr_static_config_lut_config #
BNR square root lookup table
Definition
;
Members
values: pre-calculated values of square root function.
Description
LUT implementation of square root operation.
struct ipu3_uapi_bnr_static_config_bp_ctrl_config #
Detect bad pixels (bp)
Definition
;
Members
bp_thr_gain: Defines the threshold that specifies how different a defect pixel can be from its neighbors. Threshold is dependent on de-noise threshold calculated by algorithm. Range [4, 31], default 4.reserved0: reserveddefect_mode: Mode of addressed defect pixels, 0 - single defect pixel is expected, 1 - 2 adjacent defect pixels are expected, default 1.bp_gain: Defines how 2nd derivation that passes through a defect pixel is different from 2nd derivations that pass through neighbor pixels. u4.2, range [0, 256], default 8.reserved1: reservedw0_coeff: Blending coefficient of defect pixel correction. Precision u4, range [0, 8], default 8.reserved2: reservedw1_coeff: Enable influence of incorrect defect pixel correction to be avoided. Precision u4, range [1, 8], default 8.reserved3: reserved
struct ipu3_uapi_bnr_static_config_dn_detect_ctrl_config #
Denoising config
Definition
;
Members
alpha: Weight of central element of smoothing filter.beta: Weight of peripheral elements of smoothing filter, default 4.gamma: Weight of diagonal elements of smoothing filter, default 4.reserved0: reservedmax_inf: Maximum increase of peripheral or diagonal element influence relative to the pre-defined value range: [0x5, 0xa]reserved1: reservedgd_enable: Green disparity enable control, 0 - disable, 1 - enable.bpc_enable: Bad pixel correction enable control, 0 - disable, 1 - enable.bnr_enable: Bayer noise removal enable control, 0 - disable, 1 - enable.ff_enable: Fixed function enable, 0 - disable, 1 - enable.reserved2: reserved
Description
-
beta and gamma parameter define the strength of the noise removal filter.
All above has precision u0.4, range [0, 0xf] format: u0.4 (no / zero bits represent whole number, 4 bits represent the fractional part with each count representing 0.0625) e.g. 0xf translates to 0.0625x15 = 0.9375
struct ipu3_uapi_bnr_static_config_opt_center_sqr_config #
BNR optical square
Definition
;
Members
x_sqr_reset: Reset value of X^2.y_sqr_reset: Reset value of Y^2.
Description
Please note:
- X and Y ref to
ipu3_uapi_bnr_static_config_opt_center_config - Both structs are used in threshold formula to calculate r^2, where r is a radius of pixel [row, col] from centor of sensor.
struct ipu3_uapi_bnr_static_config #
BNR static config
Definition
;
Members
wb_gains: white balance gainsipu3_uapi_bnr_static_config_wb_gains_configwb_gains_thr: white balance gains threshold as defined byipu3_uapi_bnr_static_config_wb_gains_thr_configthr_coeffs: coefficients of thresholdipu3_uapi_bnr_static_config_thr_coeffs_configthr_ctrl_shd: control of shading thresholdipu3_uapi_bnr_static_config_thr_ctrl_shd_configopt_center: optical centeripu3_uapi_bnr_static_config_opt_center_configlut: lookup tableipu3_uapi_bnr_static_config_lut_configbp_ctrl: detect and remove bad pixels as defined in structipu3_uapi_bnr_static_config_bp_ctrl_configdn_detect_ctrl: detect and remove noise.ipu3_uapi_bnr_static_config_dn_detect_ctrl_configcolumn_size: The number of pixels in column.opt_center_sqr: Reset value of r^2 to optical center, seeipu3_uapi_bnr_static_config_opt_center_sqr_config.
Description
Above parameters and opt_center_sqr are used for white balance and shading.
struct ipu3_uapi_bnr_static_config_green_disparity #
Correct green disparity
Definition
;
Members
gd_red: Shading gain coeff for gr disparity level in bright red region. Precision u0.6, default 4(0.0625).reserved0: reservedgd_green: Shading gain coeff for gr disparity level in bright green region. Precision u0.6, default 4(0.0625).reserved1: reservedgd_blue: Shading gain coeff for gr disparity level in bright blue region. Precision u0.6, default 4(0.0625).reserved2: reservedgd_black: Maximal green disparity level in dark region (stronger disparity assumed to be image detail). Precision u14, default 80.reserved3: reservedgd_shading: Change maximal green disparity level according to square distance from image center.reserved4: reservedgd_support: Lower bound for the number of second green color pixels in current pixel neighborhood with less than threshold difference from it.reserved5: reservedgd_clip: Turn green disparity clip on/off, [0, 1], default 1.gd_central_weight: Central pixel weight in 9 pixels weighted sum.
Description
The shading gain coeff of red, green, blue and black are used to calculate threshold given a pixel's color value and its coordinates in the image.
struct ipu3_uapi_dm_config #
De-mosaic parameters
Definition
;
Members
dm_en: de-mosaic enable.ch_ar_en: Checker artifacts removal enable flag. Default 0.fcc_en: False color correction (FCC) enable flag. Default 0.reserved0: reservedframe_width: do not caregamma_sc: Sharpening coefficient (coefficient of 2-d derivation of complementary color in Hamilton-Adams interpolation). u5, range [0, 31], default 8.reserved1: reservedlc_ctrl: Parameter that controls weights of Chroma Homogeneity metric in calculation of final homogeneity metric. u5, range [0, 31], default 7.reserved2: reservedcr_param1: First parameter that defines Checker artifact removal feature gain. Precision u5, range [0, 31], default 8.reserved3: reservedcr_param2: Second parameter that defines Checker artifact removal feature gain. Precision u5, range [0, 31], default 8.reserved4: reservedcoring_param: Defines power of false color correction operation. low for preserving edge colors, high for preserving gray edge artifacts. Precision u1.4, range [0, 1.9375], default 4 (0.25).reserved5: reserved
Description
The demosaic fixed function block is responsible to covert Bayer(mosaiced) images into color images based on demosaicing algorithm.
struct ipu3_uapi_ccm_mat_config #
Color correction matrix
Definition
;
Members
coeff_m11: CCM 3x3 coefficient, range [-65536, 65535]coeff_m12: CCM 3x3 coefficient, range [-8192, 8191]coeff_m13: CCM 3x3 coefficient, range [-32768, 32767]coeff_o_r: Bias 3x1 coefficient, range [-8191, 8181]coeff_m21: CCM 3x3 coefficient, range [-32767, 32767]coeff_m22: CCM 3x3 coefficient, range [-8192, 8191]coeff_m23: CCM 3x3 coefficient, range [-32768, 32767]coeff_o_g: Bias 3x1 coefficient, range [-8191, 8181]coeff_m31: CCM 3x3 coefficient, range [-32768, 32767]coeff_m32: CCM 3x3 coefficient, range [-8192, 8191]coeff_m33: CCM 3x3 coefficient, range [-32768, 32767]coeff_o_b: Bias 3x1 coefficient, range [-8191, 8181]
Description
Transform sensor specific color space to standard sRGB by applying 3x3 matrix and adding a bias vector O. The transformation is basically a rotation and translation in the 3-dimensional color spaces. Here are the defaults:
9775, -2671, 1087, 0 -1071, 8303, 815, 0 -23, -7887, 16103, 0
struct ipu3_uapi_gamma_corr_ctrl #
Gamma correction
Definition
;
Members
enable: gamma correction enable.reserved: reserved
struct ipu3_uapi_gamma_corr_lut #
Per-pixel tone mapping implemented as LUT.
Definition
;
Members
lut: 256 tabulated values of the gamma function. LUT[1].. LUT[256] format u13.0, range [0, 8191].
Description
The tone mapping operation is done by a Piece wise linear graph that is implemented as a lookup table(LUT). The pixel component input intensity is the X-axis of the graph which is the table entry.
struct ipu3_uapi_gamma_config #
Gamma config
Definition
;
Members
gc_ctrl: control of gamma correctionipu3_uapi_gamma_corr_ctrlgc_lut: lookup table of gamma correctionipu3_uapi_gamma_corr_lut
struct ipu3_uapi_csc_mat_config #
Color space conversion matrix config
Definition
;
Members
coeff_c11: Conversion matrix value, format s0.14, range [-16384, 16383].coeff_c12: Conversion matrix value, format s0.14, range [-8192, 8191].coeff_c13: Conversion matrix value, format s0.14, range [-16384, 16383].coeff_b1: Bias 3x1 coefficient, s13.0 range [-8192, 8191].coeff_c21: Conversion matrix value, format s0.14, range [-16384, 16383].coeff_c22: Conversion matrix value, format s0.14, range [-8192, 8191].coeff_c23: Conversion matrix value, format s0.14, range [-16384, 16383].coeff_b2: Bias 3x1 coefficient, s13.0 range [-8192, 8191].coeff_c31: Conversion matrix value, format s0.14, range [-16384, 16383].coeff_c32: Conversion matrix value, format s0.14, range [-8192, 8191].coeff_c33: Conversion matrix value, format s0.14, range [-16384, 16383].coeff_b3: Bias 3x1 coefficient, s13.0 range [-8192, 8191].
Description
To transform each pixel from RGB to YUV (Y - brightness/luminance, UV -chroma) by applying the pixel's values by a 3x3 matrix and adding an optional bias 3x1 vector. Here are the default values for the matrix:
4898, 9617, 1867, 0, -2410, -4732, 7143, 0, 10076, -8437, -1638, 0,
(i.e. for real number 0.299, 0.299 * 2^14 becomes 4898.)
struct ipu3_uapi_cds_params #
Chroma down-scaling
Definition
;
Members
ds_c00: range [0, 3]ds_c01: range [0, 3]ds_c02: range [0, 3]ds_c03: range [0, 3]ds_c10: range [0, 3]ds_c11: range [0, 3]ds_c12: range [0, 3]ds_c13: range [0, 3]ds_nf: Normalization factor for Chroma output downscaling filter, range 0,4, default 2.reserved0: reservedcsc_en: Color space conversion enableuv_bin_output: 0: output YUV 4.2.0, 1: output YUV 4.2.2(default).reserved1: reserved
Description
- In case user does not provide, above 4x2 filter will use following defaults: 1, 3, 3, 1, 1, 3, 3, 1,
struct ipu3_uapi_shd_grid_config #
Bayer shading(darkening) correction
Definition
;
Members
width: Grid horizontal dimensions, u8, [8, 128], default 73height: Grid vertical dimensions, u8, [8, 128], default 56block_width_log2: Log2 of the width of the grid cell in pixel count u4, [0, 15], default value 5.reserved0: reservedblock_height_log2: Log2 of the height of the grid cell in pixel count u4, [0, 15], default value 6.reserved1: reservedgrid_height_per_slice: SHD_MAX_CELLS_PER_SET/width. (with SHD_MAX_CELLS_PER_SET = 146).x_start: X value of top left corner of sensor relative to ROI s13, [-4096, 0], default 0, only negative values.y_start: Y value of top left corner of sensor relative to ROI s13, [-4096, 0], default 0, only negative values.
struct ipu3_uapi_shd_general_config #
Shading general config
Definition
;
Members
init_set_vrt_offst_ul: set vertical offset, y_start >> block_height_log2 % grid_height_per_slice.shd_enable: shading enable.gain_factor: Gain factor. Shift calculated anti shading value. Precision u2. 0x0 - gain factor [1, 5], means no shift interpolated value. 0x1 - gain factor [1, 9], means shift interpolated by 1. 0x2 - gain factor [1, 17], means shift interpolated by 2.reserved: reserved
Description
Correction is performed by multiplying a gain factor for each of the 4 Bayer channels as a function of the pixel location in the sensor.
struct ipu3_uapi_shd_black_level_config #
Black level correction
Definition
;
Members
bl_r: Bios values for green red. s11 range [-2048, 2047].bl_gr: Bios values for green blue. s11 range [-2048, 2047].bl_gb: Bios values for red. s11 range [-2048, 2047].bl_b: Bios values for blue. s11 range [-2048, 2047].
struct ipu3_uapi_shd_config_static #
Shading config static
Definition
;
Members
grid: shading grid configipu3_uapi_shd_grid_configgeneral: shading general configipu3_uapi_shd_general_configblack_level: black level config for shading correction as defined byipu3_uapi_shd_black_level_config
struct ipu3_uapi_shd_lut #
Shading gain factor lookup table.
Definition
;
Members
sets: arraysets.r_and_gr: Red and GreenR Lookup table.sets.r_and_gr.r: Red shading factor.sets.r_and_gr.gr: GreenR shading factor.sets.reserved1: reservedsets.gb_and_b: GreenB and Blue Lookup table.sets.gb_and_b.gb: GreenB shading factor.sets.gb_and_b.b: Blue shading factor.sets.reserved2: reserved
Description
Map to shading correction LUT register set.
struct ipu3_uapi_shd_config #
Shading config
Definition
;
Members
shd: shading static config, seeipu3_uapi_shd_config_staticshd_lut: shading lookup tableipu3_uapi_shd_lut
struct ipu3_uapi_iefd_cux2 #
IEFd Config Unit 2 parameters
Definition
;
Members
x0: X0 point of Config Unit, u9.0, default 0.x1: X1 point of Config Unit, u9.0, default 0.a01: Slope A of Config Unit, s4.4, default 0.b01: Slope B, always 0.
Description
Calculate weight for blending directed and non-directed denoise elements
Note
Each instance of Config Unit needs X coordinate of n points and slope A factor between points calculated by driver based on calibration parameters.
All CU inputs are unsigned, they will be converted to signed when written
to register, i.e. a01 will be written to 9 bit register in s4.4 format.
The data precision s4.4 means 4 bits for integer parts and 4 bits for the
fractional part, the first bit indicates positive or negative value.
For userspace software (commonly the imaging library), the computation for
the CU slope values should be based on the slope resolution 1/16 (binary
0.0001 - the minimal interval value), the slope value range is [-256, +255].
This applies to ipu3_uapi_iefd_cux6_ed, ipu3_uapi_iefd_cux2_1,
ipu3_uapi_iefd_cux2_1, ipu3_uapi_iefd_cux4 and ipu3_uapi_iefd_cux6_rad.
struct ipu3_uapi_iefd_cux6_ed #
Calculate power of non-directed sharpening element, Config Unit 6 for edge detail (ED).
Definition
;
Members
x0: X coordinate of point 0, u9.0, default 0.x1: X coordinate of point 1, u9.0, default 0.x2: X coordinate of point 2, u9.0, default 0.reserved0: reservedx3: X coordinate of point 3, u9.0, default 0.x4: X coordinate of point 4, u9.0, default 0.x5: X coordinate of point 5, u9.0, default 0.reserved1: reserveda01: slope A points 01, s4.4, default 0.a12: slope A points 12, s4.4, default 0.a23: slope A points 23, s4.4, default 0.reserved2: reserveda34: slope A points 34, s4.4, default 0.a45: slope A points 45, s4.4, default 0.reserved3: reservedb01: slope B points 01, s4.4, default 0.b12: slope B points 12, s4.4, default 0.b23: slope B points 23, s4.4, default 0.reserved4: reservedb34: slope B points 34, s4.4, default 0.b45: slope B points 45, s4.4, default 0.reserved5: reserved.
struct ipu3_uapi_iefd_cux2_1 #
Calculate power of non-directed denoise element apply.
Definition
;
Members
x0: X0 point of Config Unit, u9.0, default 0.x1: X1 point of Config Unit, u9.0, default 0.a01: Slope A of Config Unit, s4.4, default 0.reserved1: reservedb01: offset B0 of Config Unit, u7.0, default 0.reserved2: reserved
struct ipu3_uapi_iefd_cux4 #
Calculate power of non-directed sharpening element.
Definition
;
Members
x0: X0 point of Config Unit, u9.0, default 0.x1: X1 point of Config Unit, u9.0, default 0.x2: X2 point of Config Unit, u9.0, default 0.reserved0: reservedx3: X3 point of Config Unit, u9.0, default 0.a01: Slope A0 of Config Unit, s4.4, default 0.a12: Slope A1 of Config Unit, s4.4, default 0.reserved1: reserveda23: Slope A2 of Config Unit, s4.4, default 0.b01: Offset B0 of Config Unit, s7.0, default 0.b12: Offset B1 of Config Unit, s7.0, default 0.reserved2: reservedb23: Offset B2 of Config Unit, s7.0, default 0.reserved3: reserved
struct ipu3_uapi_iefd_cux6_rad #
Radial Config Unit (CU)
Definition
;
Members
x0: x0 points of Config Unit radial, u8.0x1: x1 points of Config Unit radial, u8.0x2: x2 points of Config Unit radial, u8.0x3: x3 points of Config Unit radial, u8.0x4: x4 points of Config Unit radial, u8.0x5: x5 points of Config Unit radial, u8.0reserved1: reserveda01: Slope A of Config Unit radial, s7.8a12: Slope A of Config Unit radial, s7.8a23: Slope A of Config Unit radial, s7.8a34: Slope A of Config Unit radial, s7.8a45: Slope A of Config Unit radial, s7.8reserved2: reservedb01: Slope B of Config Unit radial, s9.0b12: Slope B of Config Unit radial, s9.0b23: Slope B of Config Unit radial, s9.0reserved4: reservedb34: Slope B of Config Unit radial, s9.0b45: Slope B of Config Unit radial, s9.0reserved5: reserved
struct ipu3_uapi_yuvp1_iefd_cfg_units #
IEFd Config Units parameters
Definition
;
Members
cu_1: calculate weight for blending directed and non-directed denoise elements. Seeipu3_uapi_iefd_cux2cu_ed: calculate power of non-directed sharpening element, seeipu3_uapi_iefd_cux6_edcu_3: calculate weight for blending directed and non-directed denoise elements. Aipu3_uapi_iefd_cux2cu_5: calculate power of non-directed denoise element apply, useipu3_uapi_iefd_cux2_1cu_6: calculate power of non-directed sharpening element. Seeipu3_uapi_iefd_cux4cu_7: calculate weight for blending directed and non-directed denoise elements. Useipu3_uapi_iefd_cux2cu_unsharp: Config Unit of unsharpipu3_uapi_iefd_cux4cu_radial: Config Unit of radialipu3_uapi_iefd_cux6_radcu_vssnlm: Config Unit of vssnlmipu3_uapi_iefd_cux2
struct ipu3_uapi_yuvp1_iefd_config_s #
IEFd config
Definition
;
Members
horver_diag_coeff: Gradient compensation. Compared with vertical / horizontal (0 / 90 degree), coefficient of diagonal (45 / 135 degree) direction should be corrected by approx. 1/sqrt(2).reserved0: reservedclamp_stitch: Slope to stitch between clamped and unclamped edge valuesreserved1: reserveddirect_metric_update: Update coeff for direction metricreserved2: reserveded_horver_diag_coeff: Radial Coefficient that compensates for different distance for vertical/horizontal and diagonal gradient calculation (approx. 1/sqrt(2))reserved3: reserved
struct ipu3_uapi_yuvp1_iefd_control #
IEFd control
Definition
;
Members
iefd_en: Enable IEFddenoise_en: Enable denoisedirect_smooth_en: Enable directional smoothrad_en: Enable radial updatevssnlm_en: Enable VSSNLM output filterreserved: reserved
struct ipu3_uapi_sharp_cfg #
Sharpening config
Definition
;
Members
nega_lmt_txt: Sharpening limit for negative overshoots for texture.reserved0: reservedposi_lmt_txt: Sharpening limit for positive overshoots for texture.reserved1: reservednega_lmt_dir: Sharpening limit for negative overshoots for direction (edge).reserved2: reservedposi_lmt_dir: Sharpening limit for positive overshoots for direction (edge).reserved3: reserved
Description
Fixed point type u13.0, range [0, 8191].
struct ipu3_uapi_far_w #
Sharpening config for far sub-group
Definition
;
Members
dir_shrp: Weight of wide direct sharpening, u1.6, range [0, 64], default 64.reserved0: reserveddir_dns: Weight of wide direct denoising, u1.6, range [0, 64], default 0.reserved1: reservedndir_dns_powr: Power of non-direct denoising, Precision u1.6, range [0, 64], default 64.reserved2: reserved
struct ipu3_uapi_unsharp_cfg #
Unsharp config
Definition
;
Members
unsharp_weight: Unsharp mask blending weight. u1.6, range [0, 64], default 16. 0 - disabled, 64 - use only unsharp.reserved0: reservedunsharp_amount: Unsharp mask amount, u4.5, range [0, 511], default 0.reserved1: reserved
struct ipu3_uapi_yuvp1_iefd_shrp_cfg #
IEFd sharpness config
Definition
;
Members
cfg: sharpness configipu3_uapi_sharp_cfgfar_w: wide range config, value as specified byipu3_uapi_far_w: The 5x5 environment is separated into 2 sub-groups, the 3x3 nearest neighbors (8 pixels called Near), and the second order neighborhood around them (16 pixels called Far).unshrp_cfg: unsharpness config.ipu3_uapi_unsharp_cfg
struct ipu3_uapi_unsharp_coef0 #
Unsharp mask coefficients
Definition
;
Members
c00: Coeff11, s0.8, range [-255, 255], default 1.c01: Coeff12, s0.8, range [-255, 255], default 5.c02: Coeff13, s0.8, range [-255, 255], default 9.reserved: reserved
Description
Configurable registers for common sharpening support.
struct ipu3_uapi_unsharp_coef1 #
Unsharp mask coefficients
Definition
;
Members
c11: Coeff22, s0.8, range [-255, 255], default 29.c12: Coeff23, s0.8, range [-255, 255], default 55.c22: Coeff33, s0.8, range [-255, 255], default 96.reserved: reserved
struct ipu3_uapi_yuvp1_iefd_unshrp_cfg #
Unsharp mask config
Definition
;
Members
unsharp_coef0: unsharp coefficient 0 config. Seeipu3_uapi_unsharp_coef0unsharp_coef1: unsharp coefficient 1 config. Seeipu3_uapi_unsharp_coef1
struct ipu3_uapi_radial_reset_xy #
Radial coordinate reset
Definition
;
Members
x: Radial reset of x coordinate. Precision s12, [-4095, 4095], default 0.reserved0: reservedy: Radial center y coordinate. Precision s12, [-4095, 4095], default 0.reserved1: reserved
struct ipu3_uapi_radial_reset_x2 #
Radial X^2 reset
Definition
;
Members
x2: Radial reset of x^2 coordinate. Precision u24, default 0.reserved: reserved
struct ipu3_uapi_radial_reset_y2 #
Radial Y^2 reset
Definition
;
Members
y2: Radial reset of y^2 coordinate. Precision u24, default 0.reserved: reserved
struct ipu3_uapi_radial_cfg #
Radial config
Definition
;
Members
rad_nf: Radial. R^2 normalization factor is scale down by 2^ - (15 + scale)reserved0: reservedrad_inv_r2: Radial R^-2 normelized to (0.5..1). Precision u7, range [0, 127].reserved1: reserved
struct ipu3_uapi_rad_far_w #
Radial FAR sub-group
Definition
;
Members
rad_dir_far_sharp_w: Weight of wide direct sharpening, u1.6, range [0, 64], default 64.rad_dir_far_dns_w: Weight of wide direct denoising, u1.6, range [0, 64], default 0.rad_ndir_far_dns_power: power of non-direct sharpening, u1.6, range [0, 64], default 0.reserved: reserved
struct ipu3_uapi_cu_cfg0 #
Radius Config Unit cfg0 register
Definition
;
Members
cu6_pow: Power of CU6. Power of non-direct sharpening, u3.4.reserved0: reservedcu_unsharp_pow: Power of unsharp mask, u2.4.reserved1: reservedrad_cu6_pow: Radial/corner CU6. Directed sharpening power, u3.4.reserved2: reservedrad_cu_unsharp_pow: Radial power of unsharp mask, u2.4.reserved3: reserved
struct ipu3_uapi_cu_cfg1 #
Radius Config Unit cfg1 register
Definition
;
Members
rad_cu6_x1: X1 point of Config Unit 6, precision u9.0.reserved0: reservedrad_cu_unsharp_x1: X1 point for Config Unit unsharp for radial/corner point precision u9.0.reserved1: reserved
struct ipu3_uapi_yuvp1_iefd_rad_cfg #
IEFd parameters changed radially over the picture plane.
Definition
;
Members
reset_xy: reset xy value in radial calculation.ipu3_uapi_radial_reset_xyreset_x2: reset x square value in radial calculation. See structipu3_uapi_radial_reset_x2reset_y2: reset y square value in radial calculation. See structipu3_uapi_radial_reset_y2cfg: radial config defined inipu3_uapi_radial_cfgrad_far_w: weight for wide range radial.ipu3_uapi_rad_far_wcu_cfg0: configuration unit 0. Seeipu3_uapi_cu_cfg0cu_cfg1: configuration unit 1. Seeipu3_uapi_cu_cfg1
struct ipu3_uapi_vss_lut_x #
Vssnlm LUT x0/x1/x2
Definition
;
Members
vs_x0: Vssnlm LUT x0, precision u8, range [0, 255], default 16.vs_x1: Vssnlm LUT x1, precision u8, range [0, 255], default 32.vs_x2: Vssnlm LUT x2, precision u8, range [0, 255], default 64.reserved2: reserved
struct ipu3_uapi_vss_lut_y #
Vssnlm LUT y0/y1/y2
Definition
;
Members
vs_y1: Vssnlm LUT y1, precision u4, range [0, 8], default 1.reserved0: reservedvs_y2: Vssnlm LUT y2, precision u4, range [0, 8], default 3.reserved1: reservedvs_y3: Vssnlm LUT y3, precision u4, range [0, 8], default 8.reserved2: reserved
struct ipu3_uapi_yuvp1_iefd_vssnlm_cfg #
IEFd Vssnlm Lookup table
Definition
;
Members
vss_lut_x: vss lookup table. Seeipu3_uapi_vss_lut_xdescriptionvss_lut_y: vss lookup table. Seeipu3_uapi_vss_lut_ydescription
struct ipu3_uapi_yuvp1_iefd_config #
IEFd config
Definition
;
Members
units: configuration unit setting,ipu3_uapi_yuvp1_iefd_cfg_unitsconfig: configuration, as defined byipu3_uapi_yuvp1_iefd_config_scontrol: control setting, as defined byipu3_uapi_yuvp1_iefd_controlsharp: sharpness setting, as defined byipu3_uapi_yuvp1_iefd_shrp_cfgunsharp: unsharpness setting, as defined byipu3_uapi_yuvp1_iefd_unshrp_cfgrad: radial setting, as defined byipu3_uapi_yuvp1_iefd_rad_cfgvsslnm: vsslnm setting, as defined byipu3_uapi_yuvp1_iefd_vssnlm_cfg
struct ipu3_uapi_yuvp1_yds_config #
Y Down-Sampling config
Definition
;
Members
c00: range [0, 3], default 0x0c01: range [0, 3], default 0x1c02: range [0, 3], default 0x1c03: range [0, 3], default 0x0c10: range [0, 3], default 0x0c11: range [0, 3], default 0x1c12: range [0, 3], default 0x1c13: range [0, 3], default 0x0norm_factor: Normalization factor, range [0, 4], default 2 0 - divide by 1 1 - divide by 2 2 - divide by 4 3 - divide by 8 4 - divide by 16reserved0: reservedbin_output: Down sampling on Luma channel in two optional modes 0 - Bin output 4.2.0 (default), 1 output 4.2.2.reserved1: reserved
Description
Above are 4x2 filter coefficients for chroma output downscaling.
struct ipu3_uapi_yuvp1_chnr_enable_config #
Chroma noise reduction enable
Definition
;
Members
enable: enable/disable chroma noise reductionyuv_mode: 0 - YUV420, 1 - YUV422reserved0: reservedcol_size: number of columns in the frame, max width is 2560reserved1: reserved
struct ipu3_uapi_yuvp1_chnr_coring_config #
Coring thresholds for UV
Definition
;
Members
u: U coring level, u0.13, range [0.0, 1.0], default 0.0reserved0: reservedv: V coring level, u0.13, range [0.0, 1.0], default 0.0reserved1: reserved
struct ipu3_uapi_yuvp1_chnr_sense_gain_config #
Chroma noise reduction gains
Definition
;
Members
vy: Sensitivity of horizontal edge of Y, default 100vu: Sensitivity of horizontal edge of U, default 100vv: Sensitivity of horizontal edge of V, default 100reserved0: reservedhy: Sensitivity of vertical edge of Y, default 50hu: Sensitivity of vertical edge of U, default 50hv: Sensitivity of vertical edge of V, default 50reserved1: reserved
Description
All sensitivity gain parameters have precision u13.0, range [0, 8191].
struct ipu3_uapi_yuvp1_chnr_iir_fir_config #
Chroma IIR/FIR filter config
Definition
;
Members
fir_0h: Value of center tap in horizontal FIR, range [0, 32], default 8.reserved0: reservedfir_1h: Value of distance 1 in horizontal FIR, range [0, 32], default 12.reserved1: reservedfir_2h: Value of distance 2 tap in horizontal FIR, range [0, 32], default 0.dalpha_clip_val: weight for previous row in IIR, range [1, 256], default 0.reserved2: reserved
struct ipu3_uapi_yuvp1_chnr_config #
Chroma noise reduction config
Definition
;
Members
enable: chroma noise reduction enable, seeipu3_uapi_yuvp1_chnr_enable_configcoring: coring config for chroma noise reduction, seeipu3_uapi_yuvp1_chnr_coring_configsense_gain: sensitivity config for chroma noise reduction, see ipu3_uapi_yuvp1_chnr_sense_gain_configiir_fir: iir and fir config for chroma noise reduction, see ipu3_uapi_yuvp1_chnr_iir_fir_config
struct ipu3_uapi_yuvp1_y_ee_nr_lpf_config #
Luma(Y) edge enhancement low-pass filter coefficients
Definition
;
Members
a_diag: Smoothing diagonal coefficient, u5.0.reserved0: reserveda_periph: Image smoothing perpherial, u5.0.reserved1: reserveda_cent: Image Smoothing center coefficient, u5.0.reserved2: reservedenable: 0: Y_EE_NR disabled, output = input; 1: Y_EE_NR enabled.
struct ipu3_uapi_yuvp1_y_ee_nr_sense_config #
Luma(Y) edge enhancement noise reduction sensitivity gains
Definition
;
Members
edge_sense_0: Sensitivity of edge in dark area. u13.0, default 8191.reserved0: reserveddelta_edge_sense: Difference in the sensitivity of edges between the bright and dark areas. u13.0, default 0.reserved1: reservedcorner_sense_0: Sensitivity of corner in dark area. u13.0, default 0.reserved2: reserveddelta_corner_sense: Difference in the sensitivity of corners between the bright and dark areas. u13.0, default 8191.reserved3: reserved
struct ipu3_uapi_yuvp1_y_ee_nr_gain_config #
Luma(Y) edge enhancement noise reduction gain config
Definition
;
Members
gain_pos_0: Gain for positive edge in dark area. u5.0, [0, 16], default 2.reserved0: reserveddelta_gain_posi: Difference in the gain of edges between the bright and dark areas for positive edges. u5.0, [0, 16], default 0.reserved1: reservedgain_neg_0: Gain for negative edge in dark area. u5.0, [0, 16], default 8.reserved2: reserveddelta_gain_neg: Difference in the gain of edges between the bright and dark areas for negative edges. u5.0, [0, 16], default 0.reserved3: reserved
struct ipu3_uapi_yuvp1_y_ee_nr_clip_config #
Luma(Y) edge enhancement noise reduction clipping config
Definition
;
Members
clip_pos_0: Limit of positive edge in dark area u5, value [0, 16], default 8.reserved0: reserveddelta_clip_posi: Difference in the limit of edges between the bright and dark areas for positive edges. u5, value [0, 16], default 8.reserved1: reservedclip_neg_0: Limit of negative edge in dark area u5, value [0, 16], default 8.reserved2: reserveddelta_clip_neg: Difference in the limit of edges between the bright and dark areas for negative edges. u5, value [0, 16], default 8.reserved3: reserved
struct ipu3_uapi_yuvp1_y_ee_nr_frng_config #
Luma(Y) edge enhancement noise reduction fringe config
Definition
;
Members
gain_exp: Common exponent of gains, u4, [0, 8], default 2.reserved0: reservedmin_edge: Threshold for edge and smooth stitching, u13.reserved1: reservedlin_seg_param: Power of LinSeg, u4.reserved2: reservedt1: Parameter for enabling/disabling the edge enhancement, u1.0, [0, 1], default 1.t2: Parameter for enabling/disabling the smoothing, u1.0, [0, 1], default 1.reserved3: reserved
struct ipu3_uapi_yuvp1_y_ee_nr_diag_config #
Luma(Y) edge enhancement noise reduction diagonal config
Definition
;
Members
diag_disc_g: Coefficient that prioritize diagonal edge direction on horizontal or vertical for final enhancement. u4.0, [1, 15], default 1.reserved0: reservedhvw_hor: Weight of horizontal/vertical edge enhancement for hv edge. u2.2, [1, 15], default 4.dw_hor: Weight of diagonal edge enhancement for hv edge. u2.2, [1, 15], default 1.hvw_diag: Weight of horizontal/vertical edge enhancement for diagonal edge. u2.2, [1, 15], default 1.dw_diag: Weight of diagonal edge enhancement for diagonal edge. u2.2, [1, 15], default 4.reserved1: reserved
struct ipu3_uapi_yuvp1_y_ee_nr_fc_coring_config #
Luma(Y) edge enhancement noise reduction false color correction (FCC) coring config
Definition
;
Members
pos_0: Gain for positive edge in dark, u13.0, [0, 16], default 0.reserved0: reservedpos_delta: Gain for positive edge in bright, value: pos_0 + pos_delta <=16 u13.0, default 0.reserved1: reservedneg_0: Gain for negative edge in dark area, u13.0, range [0, 16], default 0.reserved2: reservedneg_delta: Gain for negative edge in bright area. neg_0 + neg_delta <=16 u13.0, default 0.reserved3: reserved
Description
Coring is a simple soft thresholding technique.
struct ipu3_uapi_yuvp1_y_ee_nr_config #
Edge enhancement and noise reduction
Definition
;
Members
lpf: low-pass filter config. Seeipu3_uapi_yuvp1_y_ee_nr_lpf_configsense: sensitivity config. Seeipu3_uapi_yuvp1_y_ee_nr_sense_configgain: gain config as defined inipu3_uapi_yuvp1_y_ee_nr_gain_configclip: clip config as defined inipu3_uapi_yuvp1_y_ee_nr_clip_configfrng: fringe config as defined inipu3_uapi_yuvp1_y_ee_nr_frng_configdiag: diagonal edge config. Seeipu3_uapi_yuvp1_y_ee_nr_diag_configfc_coring: coring config for fringe control. Seeipu3_uapi_yuvp1_y_ee_nr_fc_coring_config
struct ipu3_uapi_yuvp2_tcc_gen_control_static_config #
Total color correction general control config
Definition
;
Members
en: 0 - TCC disabled. Output = input 1 - TCC enabled.blend_shift: blend shift, Range[3, 4], default NA.gain_according_to_y_only: 0: Gain is calculated according to YUV, 1: Gain is calculated according to Y onlyreserved0: reservedgamma: Final blending coefficients. Values[-16, 16], default NA.reserved1: reserveddelta: Final blending coefficients. Values[-16, 16], default NA.reserved2: reserved
struct ipu3_uapi_yuvp2_tcc_macc_elem_static_config #
Total color correction multi-axis color control (MACC) config
Definition
;
Members
a: a coefficient for 2x2 MACC conversion matrix.reserved0: reservedb: b coefficient 2x2 MACC conversion matrix.reserved1: reservedc: c coefficient for 2x2 MACC conversion matrix.reserved2: reservedd: d coefficient for 2x2 MACC conversion matrix.reserved3: reserved
struct ipu3_uapi_yuvp2_tcc_macc_table_static_config #
Total color correction multi-axis color control (MACC) table array
Definition
;
Members
entries: config for multi axis color correction, as specified byipu3_uapi_yuvp2_tcc_macc_elem_static_config
struct ipu3_uapi_yuvp2_tcc_inv_y_lut_static_config #
Total color correction inverse y lookup table
Definition
;
Members
entries: lookup table for inverse y estimation, and use it to estimate the ratio between luma and chroma. Chroma by approximate the absolute value of the radius on the chroma plane (R = sqrt(u^2+v^2) ) and luma by approximate by 1/Y.
struct ipu3_uapi_yuvp2_tcc_gain_pcwl_lut_static_config #
Total color correction lookup table for PCWL
Definition
;
Members
entries: lookup table for gain piece wise linear transformation (PCWL)
struct ipu3_uapi_yuvp2_tcc_r_sqr_lut_static_config #
Total color correction lookup table for r square root
Definition
;
Members
entries: lookup table for r square root estimation
struct ipu3_uapi_yuvp2_tcc_static_config #
Total color correction static
Definition
;
Members
gen_control: general config for Total Color Correctionmacc_table: config for multi axis color correctioninv_y_lut: lookup table for inverse y estimationgain_pcwl: lookup table for gain PCWLr_sqr_lut: lookup table for r square root estimation.
struct ipu3_uapi_anr_transform_config #
Advanced noise reduction transform
Definition
;
Members
enable: advanced noise reduction enabled.adaptive_treshhold_en: On IPU3, adaptive threshold is always enabled.reserved1: reservedreserved2: reservedalpha: using following defaults: 13, 13, 13, 13, 0, 0, 0, 0 11, 11, 11, 11, 0, 0, 0, 0 14, 14, 14, 14, 0, 0, 0, 0beta: use following defaults: 24, 24, 24, 24 21, 20, 20, 21 25, 25, 25, 25color: use defaults defined in driver/media/pci/intel/ipu3-tables.csqrt_lut: 11 bits per element, values = [724 768 810 849 887 923 958 991 1024 1056 1116 1145 1173 1201 1086 1228 1254 1280 1305 1330 1355 1379 1402 1425 1448]xreset: Reset value of X for r^2 calculation Value: col_start-X_center Constraint: Xreset + FrameWdith=4095 Xreset= -4095, default -1632.reserved3: reservedyreset: Reset value of Y for r^2 calculation Value: row_start-Y_center Constraint: Yreset + FrameHeight=4095 Yreset= -4095, default -1224.reserved4: reservedx_sqr_reset: Reset value of X^2 for r^2 calculation Value = (Xreset)^2r_normfactor: Normalization factor for R. Default 14.reserved5: reservedy_sqr_reset: Reset value of Y^2 for r^2 calculation Value = (Yreset)^2gain_scale: Parameter describing shading gain as a function of distance from the image center. A single value per frame, loaded by the driver. Default 115.
struct ipu3_uapi_anr_stitch_pyramid #
ANR stitch pyramid
Definition
;
Members
entry0: pyramid LUT entry0, range [0x0, 0x3f]entry1: pyramid LUT entry1, range [0x0, 0x3f]entry2: pyramid LUT entry2, range [0x0, 0x3f]reserved: reserved
struct ipu3_uapi_anr_stitch_config #
ANR stitch config
Definition
;
Members
anr_stitch_en: enable stitch. Enabled with 1.reserved: reservedpyramid: pyramid table as defined byipu3_uapi_anr_stitch_pyramiddefault values: { 1, 3, 5 }, { 7, 7, 5 }, { 3, 1, 3 }, { 9, 15, 21 }, { 21, 15, 9 }, { 3, 5, 15 }, { 25, 35, 35 }, { 25, 15, 5 }, { 7, 21, 35 }, { 49, 49, 35 }, { 21, 7, 7 }, { 21, 35, 49 }, { 49, 35, 21 }, { 7, 5, 15 }, { 25, 35, 35 }, { 25, 15, 5 }, { 3, 9, 15 }, { 21, 21, 15 }, { 9, 3, 1 }, { 3, 5, 7 }, { 7, 5, 3}, { 1 }
struct ipu3_uapi_anr_config #
ANR config
Definition
;
Members
transform: advanced noise reduction transform config as specified byipu3_uapi_anr_transform_configstitch: create 4x4 patch from 4 surrounding 8x8 patches.
struct ipu3_uapi_acc_param #
Accelerator cluster parameters
Definition
;
Members
bnr: parameters for bayer noise reduction static config. Seeipu3_uapi_bnr_static_configgreen_disparity: disparity static config between gr and gb channel. Seeipu3_uapi_bnr_static_config_green_disparitydm: de-mosaic config. Seeipu3_uapi_dm_configccm: color correction matrix. Seeipu3_uapi_ccm_mat_configgamma: gamma correction config. Seeipu3_uapi_gamma_configcsc: color space conversion matrix. Seeipu3_uapi_csc_mat_configcds: color down sample config. Seeipu3_uapi_cds_paramsshd: lens shading correction config. Seeipu3_uapi_shd_configiefd: Image enhancement filter and denoise config.ipu3_uapi_yuvp1_iefd_configyds_c0: y down scaler config.ipu3_uapi_yuvp1_yds_configchnr_c0: chroma noise reduction config.ipu3_uapi_yuvp1_chnr_configy_ee_nr: y edge enhancement and noise reduction config.ipu3_uapi_yuvp1_y_ee_nr_configyds: y down scaler config. Seeipu3_uapi_yuvp1_yds_configchnr: chroma noise reduction config. Seeipu3_uapi_yuvp1_chnr_configyds2: y channel down scaler config. Seeipu3_uapi_yuvp1_yds_configtcc: total color correction config as defined in structipu3_uapi_yuvp2_tcc_static_configanr: advanced noise reduction config.Seeipu3_uapi_anr_configawb_fr: AWB filter response config. See ipu3_uapi_awb_fr_configae: auto exposure config As specified byipu3_uapi_ae_configaf: auto focus config. As specified byipu3_uapi_af_configawb: auto white balance config. As specified byipu3_uapi_awb_config
Description
ACC refers to the HW cluster containing all Fixed Functions (FFs). Each FF implements a specific algorithm.
struct ipu3_uapi_isp_lin_vmem_params #
Linearization parameters
Definition
;
Members
lin_lutlow_gr: linearization look-up table for GR channel interpolation.lin_lutlow_r: linearization look-up table for R channel interpolation.lin_lutlow_b: linearization look-up table for B channel interpolation.lin_lutlow_gb: linearization look-up table for GB channel interpolation. lin_lutlow_gr / lin_lutlow_r / lin_lutlow_b / lin_lutlow_gb <= LIN_MAX_VALUE - 1.lin_lutdif_gr: lin_lutlow_gr[i+1] - lin_lutlow_gr[i].lin_lutdif_r: lin_lutlow_r[i+1] - lin_lutlow_r[i].lin_lutdif_b: lin_lutlow_b[i+1] - lin_lutlow_b[i].lin_lutdif_gb: lin_lutlow_gb[i+1] - lin_lutlow_gb[i].
struct ipu3_uapi_isp_tnr3_vmem_params #
Temporal noise reduction vector memory parameters
Definition
;
Members
slope: slope setting in interpolation curve for temporal noise reduction.reserved1: reservedsigma: knee point setting in interpolation curve for temporal noise reduction.reserved2: reserved
struct ipu3_uapi_isp_tnr3_params #
Temporal noise reduction v3 parameters
Definition
;
Members
knee_y1: Knee point TNR3 assumes standard deviation of Y,U and V at Y1 are TnrY1_Sigma_Y, U and V.knee_y2: Knee point TNR3 assumes standard deviation of Y,U and V at Y2 are TnrY2_Sigma_Y, U and V.maxfb_y: Max feedback gain for Ymaxfb_u: Max feedback gain for Umaxfb_v: Max feedback gain for Vround_adj_y: rounding Adjust for Yround_adj_u: rounding Adjust for Uround_adj_v: rounding Adjust for Vref_buf_select: selection of the reference frame buffer to be used.
struct ipu3_uapi_isp_xnr3_vmem_params #
Extreme noise reduction v3 vector memory parameters
Definition
;
Members
x: xnr3 parameters.a: xnr3 parameters.b: xnr3 parameters.c: xnr3 parameters.
struct ipu3_uapi_xnr3_alpha_params #
Extreme noise reduction v3 alpha tuning parameters
Definition
;
Members
y0: Sigma for Y range similarity in dark area.u0: Sigma for U range similarity in dark area.v0: Sigma for V range similarity in dark area.ydiff: Sigma difference for Y between bright area and dark area.udiff: Sigma difference for U between bright area and dark area.vdiff: Sigma difference for V between bright area and dark area.
struct ipu3_uapi_xnr3_coring_params #
Extreme noise reduction v3 coring parameters
Definition
;
Members
u0: Coring Threshold of U channel in dark area.v0: Coring Threshold of V channel in dark area.udiff: Threshold difference of U channel between bright and dark area.vdiff: Threshold difference of V channel between bright and dark area.
struct ipu3_uapi_xnr3_blending_params #
Blending factor
Definition
;
Members
strength: The factor for blending output with input. This is tuning parameterHigher values lead to more aggressive XNR operation.
struct ipu3_uapi_isp_xnr3_params #
Extreme noise reduction v3 parameters
Definition
;
Members
alpha: parameters for xnr3 alpha. Seeipu3_uapi_xnr3_alpha_paramscoring: parameters for xnr3 coring. Seeipu3_uapi_xnr3_coring_paramsblending: parameters for xnr3 blending. Seeipu3_uapi_xnr3_blending_params
struct ipu3_uapi_obgrid_param #
Optical black level compensation parameters
Definition
;
Members
gr: Grid table values for color GRr: Grid table values for color Rb: Grid table values for color Bgb: Grid table values for color GB
Description
Black level is different for red, green, and blue channels. So black level compensation is different per channel.
struct ipu3_uapi_flags #
bits to indicate which pipeline needs update
Definition
;
Members
gdc: 0 = no update, 1 = update.obgrid: 0 = no update, 1 = update.reserved1: Not used.acc_bnr: 0 = no update, 1 = update.acc_green_disparity: 0 = no update, 1 = update.acc_dm: 0 = no update, 1 = update.acc_ccm: 0 = no update, 1 = update.acc_gamma: 0 = no update, 1 = update.acc_csc: 0 = no update, 1 = update.acc_cds: 0 = no update, 1 = update.acc_shd: 0 = no update, 1 = update.reserved2: Not used.acc_iefd: 0 = no update, 1 = update.acc_yds_c0: 0 = no update, 1 = update.acc_chnr_c0: 0 = no update, 1 = update.acc_y_ee_nr: 0 = no update, 1 = update.acc_yds: 0 = no update, 1 = update.acc_chnr: 0 = no update, 1 = update.acc_ytm: 0 = no update, 1 = update.acc_yds2: 0 = no update, 1 = update.acc_tcc: 0 = no update, 1 = update.acc_dpc: 0 = no update, 1 = update.acc_bds: 0 = no update, 1 = update.acc_anr: 0 = no update, 1 = update.acc_awb_fr: 0 = no update, 1 = update.acc_ae: 0 = no update, 1 = update.acc_af: 0 = no update, 1 = update.acc_awb: 0 = no update, 1 = update.reserved3: Not used.lin_vmem_params: 0 = no update, 1 = update.tnr3_vmem_params: 0 = no update, 1 = update.xnr3_vmem_params: 0 = no update, 1 = update.tnr3_dmem_params: 0 = no update, 1 = update.xnr3_dmem_params: 0 = no update, 1 = update.reserved4: Not used.obgrid_param: 0 = no update, 1 = update.reserved5: Not used.
struct ipu3_uapi_params #
V4L2_META_FMT_IPU3_PARAMS
Definition
;
Members
use: select which parameters to apply, seeipu3_uapi_flagsacc_param: ACC parameters, as specified byipu3_uapi_acc_paramlin_vmem_params: linearization VMEM, as specified byipu3_uapi_isp_lin_vmem_paramstnr3_vmem_params: tnr3 VMEM as specified byipu3_uapi_isp_tnr3_vmem_paramsxnr3_vmem_params: xnr3 VMEM as specified byipu3_uapi_isp_xnr3_vmem_paramstnr3_dmem_params: tnr3 DMEM as specified byipu3_uapi_isp_tnr3_paramsxnr3_dmem_params: xnr3 DMEM as specified byipu3_uapi_isp_xnr3_paramsobgrid_param: obgrid parameters as specified byipu3_uapi_obgrid_param
Description
The video queue "parameters" is of format V4L2_META_FMT_IPU3_PARAMS. This is a "single plane" v4l2_meta_format using V4L2_BUF_TYPE_META_OUTPUT.
struct ipu3_uapi_params as defined below contains a lot of parameters and ipu3_uapi_flags selects which parameters to apply.
V4L2_META_FMT_RPI_BE_CFG
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Raspberry Pi PiSP Back End configuration format #
The Raspberry Pi PiSP Back End memory-to-memory image signal processor is configured by userspace by providing a buffer of configuration parameters to the pispbe-config output video device node using the v4l2_meta_format interface.
The PiSP Back End processes images in tiles, and its configuration requires specifying two different sets of parameters by populating the members of pisp_be_tiles_config defined in the pisp_be_config.h header file.
The Raspberry Pi PiSP technical specification provide detailed description of the ISP back end configuration and programming model.
Global configuration data #
The global configuration data describe how the pixels in a particular image are to be processed and is therefore shared across all the tiles of the image. So for example, LSC (Lens Shading Correction) or Denoise parameters would be common across all tiles from the same frame.
Global configuration data are passed to the ISP by populating the member of pisp_be_config.
Tile parameters #
As the ISP processes images in tiles, each set of tiles parameters describe how a single tile in an image is going to be processed. A single set of tile parameters consist of 160 bytes of data and to process a batch of tiles several sets of tiles parameters are required.
Tiles parameters are passed to the ISP by populating the member of pisp_tile and the num_tiles fields of pisp_be_tiles_config.
Raspberry Pi PiSP Back End uAPI data types #
This section describes the data types exposed to userspace by the Raspberry Pi PiSP Back End. The section is informative only, for a detailed description of each field refer to the Raspberry Pi PiSP technical specification.
struct pisp_be_global_config #
PiSP global enable bitmaps
Definition
;
Members
bayer_enables: Bayer input enable flagsrgb_enables: RGB output enable flagsbayer_order: Bayer input format orderingpad: Padding bytes
struct pisp_be_input_buffer_config #
PiSP Back End input buffer
Definition
;
Members
addr: Input buffer address
struct pisp_be_dpc_config #
PiSP Back End DPC config
Definition
;
Members
coeff_level: Coefficient for the darkest neighbouring pixel valuecoeff_range: Coefficient for the range of pixels for this Bayer channelpad: Padding byteflags: DPC configuration flags
Description
Defective Pixel Correction configuration
struct pisp_be_geq_config #
PiSP Back End GEQ config
Definition
;
Members
offset: Offset value for threshold calculationslope_sharper: Slope/Sharper configurationmin: Minimum value the threshold may havemax: Maximum value the threshold may have
Description
Green Equalisation configuration
struct pisp_be_tdn_input_buffer_config #
PiSP Back End TDN input buffer
Definition
;
Members
addr: TDN input buffer address
struct pisp_be_tdn_config #
PiSP Back End TDN config
Definition
;
Members
black_level: Black level value subtracted from pixelsratio: Multiplier for the LTA input framenoise_constant: Constant offset value used in noise estimationnoise_slope: Noise estimation multiplierthreshold: Threshold for TDN operationsreset: Disable TDN operationspad: Padding byte
Description
Temporal Denoise configuration
struct pisp_be_tdn_output_buffer_config #
PiSP Back End TDN output buffer
Definition
;
Members
addr: TDN output buffer address
struct pisp_be_sdn_config #
PiSP Back End SDN config
Definition
;
Members
black_level: Black level subtracted from pixel for noise estimationleakage: Proportion of the original undenoised value to mix in denoised outputpad: Padding bytenoise_constant: Noise constant used for noise estimationnoise_slope: Noise slope value used for noise estimationnoise_constant2: Second noise constant used for noise estimationnoise_slope2: Second slope value used for noise estimation
Description
Spatial Denoise configuration
struct pisp_be_stitch_input_buffer_config #
PiSP Back End Stitch input
Definition
;
Members
addr: Stitch input buffer address
struct pisp_be_stitch_config #
PiSP Back End Stitch config
Definition
;
Members
threshold_lo: Low threshold valuethreshold_diff_power: Low and high threshold differencepad: Padding bytesexposure_ratio: Multiplier to convert long exposure pixels into short exposure pixelsmotion_threshold_256: Motion threshold above which short exposure pixels are usedmotion_threshold_recip: Reciprocal of motion_threshold_256 value
Description
Stitch block configuration
struct pisp_be_stitch_output_buffer_config #
PiSP Back End Stitch output
Definition
;
Members
addr: Stitch input buffer address
struct pisp_be_cdn_config #
PiSP Back End CDN config
Definition
;
Members
thresh: Constant for noise estimationiir_strength: Relative strength of the IIR part of the filterg_adjust: Proportion of the change assigned to the G channel
Description
Colour Denoise configuration
struct pisp_be_lsc_config #
PiSP Back End LSC config
Definition
;
Members
grid_step_x: Reciprocal of cell size widthgrid_step_y: Reciprocal of cell size heightlut_packed: Jointly-coded RGB gains for each LSC grid
Description
Lens Shading Correction configuration
struct pisp_be_lsc_extra #
PiSP Back End LSC Extra config
Definition
;
Members
offset_x: Horizontal offset into the LSC table of this tileoffset_y: Vertical offset into the LSC table of this tile
struct pisp_be_cac_config #
PiSP Back End CAC config
Definition
;
Members
grid_step_x: Reciprocal of cell size widthgrid_step_y: Reciprocal of cell size heightlut: Pixel shift for the CAC grid
Description
Chromatic Aberration Correction config
struct pisp_be_cac_extra #
PiSP Back End CAC extra config
Definition
;
Members
offset_x: Horizontal offset into the CAC table of this tileoffset_y: Horizontal offset into the CAC table of this tile
struct pisp_be_debin_config #
PiSP Back End Debin config
Definition
;
Members
coeffs: Filter coefficients for debinningh_enable: Horizontal debinning enablev_enable: Vertical debinning enablepad: Padding bytes
Description
Debinning configuration
struct pisp_be_tonemap_config #
PiSP Back End Tonemap config
Definition
;
Members
detail_constant: Constant value for threshold calculationdetail_slope: Slope value for threshold calculationiir_strength: Relative strength of the IIR fiterstrength: Strength factorlut: Look-up table for tonemap curve
Description
Tonemapping configuration
struct pisp_be_demosaic_config #
PiSP Back End Demosaic config
Definition
;
Members
sharper: Use other Bayer channels to increase sharpnessfc_mode: Built-in false colour suppression modepad: Padding bytes
Description
Demosaic configuration
struct pisp_be_ccm_config #
PiSP Back End CCM config
Definition
;
Members
coeffs: Matrix coefficientspad: Padding bytesoffsets: Offsets triplet
Description
Colour Correction Matrix configuration
struct pisp_be_sat_control_config #
PiSP Back End SAT config
Definition
;
Members
shift_r: Left shift for Red colour channelshift_g: Left shift for Green colour channelshift_b: Left shift for Blue colour channelpad: Padding byte
Description
Saturation Control configuration
struct pisp_be_false_colour_config #
PiSP Back End False Colour config
Definition
;
Members
distance: Distance of neighbouring pixels, either 1 or 2pad: Padding bytes
Description
False Colour configuration
struct pisp_be_sharpen_config #
PiSP Back End Sharpening config
Definition
;
Members
kernel0: Coefficient for filter 0pad0: Padding bytekernel1: Coefficient for filter 1pad1: Padding bytekernel2: Coefficient for filter 2pad2: Padding bytekernel3: Coefficient for filter 3pad3: Padding bytekernel4: Coefficient for filter 4pad4: Padding bytethreshold_offset0: Offset for filter 0 response calculationthreshold_slope0: Slope multiplier for the filter 0 response calculationscale0: Scale factor for filter 0 response calculationpad5: Padding bytethreshold_offset1: Offset for filter 0 response calculationthreshold_slope1: Slope multiplier for the filter 0 response calculationscale1: Scale factor for filter 0 response calculationpad6: Padding bytethreshold_offset2: Offset for filter 0 response calculationthreshold_slope2: Slope multiplier for the filter 0 response calculationscale2: Scale factor for filter 0 response calculationpad7: Padding bytethreshold_offset3: Offset for filter 0 response calculationthreshold_slope3: Slope multiplier for the filter 0 response calculationscale3: Scale factor for filter 0 response calculationpad8: Padding bytethreshold_offset4: Offset for filter 0 response calculationthreshold_slope4: Slope multiplier for the filter 0 response calculationscale4: Scale factor for filter 0 response calculationpad9: Padding bytepositive_strength: Factor to scale the positive sharpening strengthpositive_pre_limit: Maximum allowed possible positive sharpening valuepositive_func: Gain factor applied to positive sharpening responsepositive_limit: Final gain factor applied to positive sharpeningnegative_strength: Factor to scale the negative sharpening strengthnegative_pre_limit: Maximum allowed possible negative sharpening valuenegative_func: Gain factor applied to negative sharpening responsenegative_limit: Final gain factor applied to negative sharpeningenables: Filter enable maskwhite: White output pixel filter maskblack: Black output pixel filter maskgrey: Grey output pixel filter mask
Description
Sharpening configuration
struct pisp_be_sh_fc_combine_config #
PiSP Back End Sharpening and False Colour config
Definition
;
Members
y_factor: Control amount of desaturation of pixels being darkenedc1_factor: Control amount of brightening of a pixel for the Cb channelc2_factor: Control amount of brightening of a pixel for the Cr channelpad: Padding byte
Description
Sharpening and False Colour configuration
struct pisp_be_gamma_config #
PiSP Back End Gamma configuration
Definition
;
Members
lut: Gamma curve look-up table
struct pisp_be_crop_config #
PiSP Back End Crop config
Definition
;
Members
offset_x: Number of pixels cropped from the left of the tileoffset_y: Number of pixels cropped from the top of the tilewidth: Width of the cropped tile outputheight: Height of the cropped tile output
Description
Crop configuration
struct pisp_be_resample_config #
PiSP Back End Resampling config
Definition
;
Members
scale_factor_h: Horizontal scale factorscale_factor_v: Vertical scale factorcoef: Resample coefficients
Description
Resample configuration
struct pisp_be_resample_extra #
PiSP Back End Resample config
Definition
;
Members
scaled_width: Width in pixels of the scaled outputscaled_height: Height in pixels of the scaled outputinitial_phase_h: Initial horizontal phaseinitial_phase_v: Initial vertical phase
Description
Resample configuration
struct pisp_be_downscale_config #
PiSP Back End Downscale config
Definition
;
Members
scale_factor_h: Horizontal scale factorscale_factor_v: Vertical scale factorscale_recip_h: Horizontal reciprocal factorscale_recip_v: Vertical reciprocal factor
Description
Downscale configuration
struct pisp_be_downscale_extra #
PiSP Back End Downscale Extra config
Definition
;
Members
scaled_width: Scaled image widthscaled_height: Scaled image height
struct pisp_be_hog_config #
PiSP Back End HOG config
Definition
;
Members
compute_signed: Set 0 for unsigned gradients, 1 for signedchannel_mix: Channels proportions to usestride: Stride in bytes between blocks directly below
Description
Histogram of Oriented Gradients configuration
enum pisp_be_transform #
PiSP Back End Transform flags
Constants
PISP_BE_TRANSFORM_NONE: No transformPISP_BE_TRANSFORM_HFLIP: Horizontal flipPISP_BE_TRANSFORM_VFLIP: Vertical flipPISP_BE_TRANSFORM_ROT180: 180 degress rotation
struct pisp_be_output_buffer_config #
PiSP Back End Output buffer
Definition
;
Members
addr: Output buffer address
struct pisp_be_hog_buffer_config #
PiSP Back End HOG buffer
Definition
;
Members
addr: HOG buffer address
struct pisp_be_config #
RaspberryPi PiSP Back End Processing configuration
Definition
;
Members
input_buffer: Input buffer addressestdn_input_buffer: TDN input buffer addressesstitch_input_buffer: Stitch input buffer addressestdn_output_buffer: TDN output buffer addressesstitch_output_buffer: Stitch output buffer addressesoutput_buffer: Output buffers addresseshog_buffer: HOG buffer addressesglobal: Global PiSP configurationinput_format: Input image formatdecompress: Decompress configurationdpc: Defective Pixel Correction configurationgeq: Green Equalisation configurationtdn_input_format: Temporal Denoise input formattdn_decompress: Temporal Denoise decompress configurationtdn: Temporal Denoise configurationtdn_compress: Temporal Denoise compress configurationtdn_output_format: Temporal Denoise output formatsdn: Spatial Denoise configurationblc: Black Level Correction configurationstitch_compress: Stitch compress configurationstitch_output_format: Stitch output formatstitch_input_format: Stitch input formatstitch_decompress: Stitch decompress configurationstitch: Stitch configurationlsc: Lens Shading Correction configurationwbg: White Balance Gain configurationcdn: Colour Denoise configurationcac: Colour Aberration Correction configurationdebin: Debinning configurationtonemap: Tonemapping configurationdemosaic: Demosaicing configurationccm: Colour Correction Matrix configurationsat_control: Saturation Control configurationycbcr: YCbCr colour correction configurationsharpen: Sharpening configurationfalse_colour: False colour correctionsh_fc_combine: Sharpening and False Colour correctionycbcr_inverse: Inverse YCbCr colour correctiongamma: Gamma curve configurationcsc: Color Space Conversion configurationdownscale: Downscale configurationresample: Resampling configurationoutput_format: Output format configurationhog: HOG configurationaxi: AXI bus configurationlsc_extra: LSC extra infocac_extra: CAC extra infodownscale_extra: Downscaler extra inforesample_extra: Resample extra infocrop: Crop configurationhog_format: HOG format infodirty_flags_bayer: Bayer enable dirty flags (pisp_be_bayer_enable)dirty_flags_rgb: RGB enable dirty flags (pisp_be_rgb_enable)dirty_flags_extra: Extra dirty flags
enum pisp_tile_edge #
PiSP Back End Tile position
Constants
PISP_LEFT_EDGE: Left edge tilePISP_RIGHT_EDGE: Right edge tilePISP_TOP_EDGE: Top edge tilePISP_BOTTOM_EDGE: Bottom edge tile
struct pisp_tile #
Raspberry Pi PiSP Back End tile configuration
Definition
;
Members
edge: Edge tile flagpad0: Padding bytesinput_addr_offset: Top-left pixel offset, in bytesinput_addr_offset2: Top-left pixel offset, in bytes for the second/ third image planesinput_offset_x: Horizontal offset in pixels of this tile in the input imageinput_offset_y: Vertical offset in pixels of this tile in the input imageinput_width: Width in pixels of this tileinput_height: Height in pixels of the this tiletdn_input_addr_offset: TDN input image offset, in bytestdn_output_addr_offset: TDN output image offset, in bytesstitch_input_addr_offset: Stitch input image offset, in bytesstitch_output_addr_offset: Stitch output image offset, in byteslsc_grid_offset_x: Horizontal offset in the LSC table for this tilelsc_grid_offset_y: Vertical offset in the LSC table for this tilecac_grid_offset_x: Horizontal offset in the CAC table for this tilecac_grid_offset_y: Horizontal offset in the CAC table for this tilecrop_x_start: Number of pixels cropped from the left of the tilecrop_x_end: Number of pixels cropped from the right of the tilecrop_y_start: Number of pixels cropped from the top of the tilecrop_y_end: Number of pixels cropped from the bottom of the tiledownscale_phase_x: Initial horizontal phase in pixelsdownscale_phase_y: Initial vertical phase in pixelsresample_in_width: Width in pixels of the tile entering the Resample blockresample_in_height: Height in pixels of the tile entering the Resample blockresample_phase_x: Initial horizontal phase for the Resample blockresample_phase_y: Initial vertical phase for the Resample blockoutput_offset_x: Horizontal offset in pixels where the tile will be written into the output imageoutput_offset_y: Vertical offset in pixels where the tile will be written into the output imageoutput_width: Width in pixels in the output image of this tileoutput_height: Height in pixels in the output image of this tileoutput_addr_offset: Offset in bytes into the output bufferoutput_addr_offset2: Offset in bytes into the output buffer for the second and third planeoutput_hog_addr_offset: Offset in bytes into the HOG buffer where results of this tile are to be written
Description
Tile parameters: each set of tile parameters is a 160-bytes block of data which contains the tile processing parameters.
struct pisp_be_tiles_config #
Raspberry Pi PiSP Back End configuration
Definition
;
Members
config: PiSP Back End configurationtiles: Tile descriptorsnum_tiles: Number of tiles
V4L2_META_FMT_RPI_FE_CFG
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
V4L2_META_FMT_RPI_FE_CFG #
Raspberry Pi PiSP Front End configuration format #
The Raspberry Pi PiSP Front End image signal processor is configured by userspace by providing a buffer of configuration parameters to the rp1-cfe-fe-config output video device node using the v4l2_meta_format interface.
The Raspberry Pi PiSP technical specification provide detailed description of the Front End configuration and programming model.
V4L2_META_FMT_RPI_FE_STATS #
Raspberry Pi PiSP Front End statistics format #
The Raspberry Pi PiSP Front End image signal processor provides statistics data by writing to a buffer provided via the rp1-cfe-fe-stats capture video device node using the v4l2_meta_format interface.
The Raspberry Pi PiSP technical specification provide detailed description of the Front End configuration and programming model.
V4L2_META_FMT_RK_ISP1_PARAMS ('rk1p'), V4L2_META_FMT_RK_ISP1_STAT_3A ('rk1s'), V4L2_META_FMT_RK_ISP1_EXT_PARAMS ('rk1e')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Configuration parameters #
The configuration of the RkISP1 ISP is performed by userspace by providing parameters for the ISP to the driver using the v4l2_meta_format interface.
There are two methods that allow to configure the ISP, the fixed parameters configuration format and the extensible parameters configuration format.
Fixed parameters configuration format #
When using the fixed configuration format, parameters are passed to the rkisp1_params metadata output video node, using the V4L2_META_FMT_RK_ISP1_PARAMS meta format.
The buffer contains a single instance of the C structure rkisp1_params_cfg defined in rkisp1-config.h. So the structure can be obtained from the buffer by:
struct rkisp1_params_cfg *params = buffer;
This method supports a subset of the ISP features only, new applications should use the extensible parameters method.
Extensible parameters configuration format #
When using the extensible configuration format, parameters are passed to the rkisp1_params metadata output video node, using the V4L2_META_FMT_RK_ISP1_EXT_PARAMS meta format.
The buffer contains a single instance of the C structure rkisp1_ext_params_cfg defined in rkisp1-config.h. The rkisp1_ext_params_cfg structure is designed to allow userspace to populate the data buffer with only the configuration data for the ISP blocks it intends to configure. The extensible parameters format design allows developers to define new block types to support new configuration parameters, and defines a versioning scheme so that it can be extended and versioned without breaking compatibility with existing applications.
For these reasons, this configuration method is preferred over the fixed parameters format alternative.
3A and histogram statistics #
The ISP1 device collects different statistics over an input Bayer frame. Those statistics are obtained from the rkisp1_stats metadata capture video node, using the v4l2_meta_format interface. The buffer contains a single instance of the C structure rkisp1_stat_buffer defined in rkisp1-config.h. So the structure can be obtained from the buffer by:
struct rkisp1_stat_buffer *stats = buffer;
The statistics collected are Exposure, AWB (Auto-white balance), Histogram and AF (Auto-focus). See rkisp1_stat_buffer for details of the statistics.
The 3A statistics and configuration parameters described here are usually consumed and produced by dedicated user space libraries that comprise the important tuning tools using software control loop.
rkisp1 uAPI data types #
enum rkisp1_cif_isp_version #
ISP variants
Constants
RKISP1_V10: Used at least in RK3288 and RK3399.RKISP1_V11: Declared in the original vendor code, but not used. Same number of entries in grids and histogram as v10.RKISP1_V12: Used at least in RK3326 and PX30.RKISP1_V13: Used at least in RK1808. Same number of entries in grids and histogram as v12.RKISP1_V_IMX8MP: Used in at least i.MX8MP. Same number of entries in grids and histogram as v10.
enum rkisp1_cif_isp_exp_ctrl_autostop #
stop modes
Constants
RKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_0: continuous measurementRKISP1_CIF_ISP_EXP_CTRL_AUTOSTOP_1: stop measuring after a complete frame
enum rkisp1_cif_isp_exp_meas_mode #
Exposure measure mode
Constants
RKISP1_CIF_ISP_EXP_MEASURING_MODE_0: Y = 16 + 0.25R + 0.5G + 0.1094BRKISP1_CIF_ISP_EXP_MEASURING_MODE_1: Y = (R + G + B) x (85/256)
struct rkisp1_cif_isp_window #
measurement window.
Definition
;
Members
h_offs: the horizontal offset of the window from the left of the frame in pixels.v_offs: the vertical offset of the window from the top of the frame in pixels.h_size: the horizontal size of the window in pixelsv_size: the vertical size of the window in pixels.
Description
Measurements are calculated per window inside the frame. This struct represents a window for a measurement.
struct rkisp1_cif_isp_bls_fixed_val #
BLS fixed subtraction values
Definition
;
Members
r: Fixed (signed!) subtraction value for Bayer pattern Rgr: Fixed (signed!) subtraction value for Bayer pattern Grgb: Fixed (signed!) subtraction value for Bayer pattern Gbb: Fixed (signed!) subtraction value for Bayer pattern B
Description
The values will be subtracted from the sensor values. Therefore a negative value means addition instead of subtraction!
struct rkisp1_cif_isp_bls_config #
Configuration used by black level subtraction
Definition
;
Members
enable_auto: Automatic mode activated means that the measured values are subtracted. Otherwise the fixed subtraction values will be subtracted.en_windows: enabled windowbls_window1: Measurement window 1 sizebls_window2: Measurement window 2 sizebls_samples: Set amount of measured pixels for each Bayer position (A, B,C and D) to 2^bls_samples.fixed_val: Fixed subtraction values
struct rkisp1_cif_isp_dpcc_methods_config #
DPCC methods set configuration
Definition
;
Members
method: Method enable bits (RKISP1_CIF_ISP_DPCC_METHODS_SET_*)line_thresh: Line threshold (RKISP1_CIF_ISP_DPCC_LINE_THRESH_*)line_mad_fac: Line Mean Absolute Difference factor (RKISP1_CIF_ISP_DPCC_LINE_MAD_FAC_*)pg_fac: Peak gradient factor (RKISP1_CIF_ISP_DPCC_PG_FAC_*)rnd_thresh: Rank Neighbor Difference threshold (RKISP1_CIF_ISP_DPCC_RND_THRESH_*)rg_fac: Rank gradient factor (RKISP1_CIF_ISP_DPCC_RG_FAC_*)
Description
This structure stores the configuration of one set of methods for the DPCC algorithm. Multiple methods can be selected in each set (independently for the Green and Red/Blue components) through the method field, the result is the logical AND of all enabled methods. The remaining fields set thresholds and factors for each method.
struct rkisp1_cif_isp_dpcc_config #
Configuration used by DPCC
Definition
;
Members
mode: DPCC mode (RKISP1_CIF_ISP_DPCC_MODE_*)output_mode: Interpolation output mode (RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_*)set_use: Methods sets selection (RKISP1_CIF_ISP_DPCC_SET_USE_*)methods: Methods sets configurationro_limits: Rank order limits (RKISP1_CIF_ISP_DPCC_RO_LIMITS_*)rnd_offs: Differential rank offsets for rank neighbor difference (RKISP1_CIF_ISP_DPCC_RND_OFFS_*)
Description
Configuration used by Defect Pixel Cluster Correction. Three sets of methods can be configured and selected through the set_use field. The result is the logical OR of all enabled sets.
struct rkisp1_cif_isp_gamma_corr_curve #
gamma curve point definition y-axis (output).
Definition
;
Members
gamma_y: the values for the y-axis of gamma curve points. Each value is 12 bit.
Description
The reset values define a linear curve which has the same effect as bypass. Reset values are: gamma_y[0] = 0x0000, gamma_y[1] = 0x0100, ... gamma_y[15] = 0x0f00, gamma_y[16] = 0xfff
struct rkisp1_cif_isp_gamma_curve_x_axis_pnts #
De-Gamma Curve definition x increments (sampling points). gamma_dx0 is for the lower samples (1-8), gamma_dx1 is for the higher samples (9-16). The reset values for both fields is 0x44444444. This means that each sample is 4 units away from the previous one on the x-axis.
Definition
;
Members
gamma_dx0: gamma curve sample points definitions. Bits 0:2 for sample 1. Bit 3 unused. Bits 4:6 for sample 2. bit 7 unused ... Bits 28:30 for sample 8. Bit 31 unusedgamma_dx1: gamma curve sample points definitions. Bits 0:2 for sample 9. Bit 3 unused. Bits 4:6 for sample 10. bit 7 unused ... Bits 28:30 for sample 16. Bit 31 unused
struct rkisp1_cif_isp_sdg_config #
Configuration used by sensor degamma
Definition
;
Members
curve_r: gamma curve point definition axis for redcurve_g: gamma curve point definition axis for greencurve_b: gamma curve point definition axis for bluexa_pnts: x axis increments
struct rkisp1_cif_isp_lsc_config #
Configuration used by Lens shading correction
Definition
;
Members
r_data_tbl: sample table redgr_data_tbl: sample table green (red)gb_data_tbl: sample table green (blue)b_data_tbl: sample table bluex_grad_tbl: gradient table xy_grad_tbl: gradient table yx_size_tbl: size table xy_size_tbl: size table yconfig_width: not used at the momentconfig_height: not used at the moment
struct rkisp1_cif_isp_ie_config #
Configuration used by image effects
Definition
;
Members
effect: values from 'enum v4l2_colorfx'. Possible values are: V4L2_COLORFX_SEPIA, V4L2_COLORFX_SET_CBCR, V4L2_COLORFX_AQUA, V4L2_COLORFX_EMBOSS, V4L2_COLORFX_SKETCH, V4L2_COLORFX_BW, V4L2_COLORFX_NEGATIVEcolor_sel: bits 0:2 - colors bitmask (001 - blue, 010 - green, 100 - red). bits 8:15 - Threshold value of the RGB colors for the color selection effect.eff_mat_1: 3x3 Matrix Coefficients for Emboss Effect 1eff_mat_2: 3x3 Matrix Coefficients for Emboss Effect 2eff_mat_3: 3x3 Matrix Coefficients for Emboss 3/Sketch 1eff_mat_4: 3x3 Matrix Coefficients for Sketch Effect 2eff_mat_5: 3x3 Matrix Coefficients for Sketch Effect 3eff_tint: Chrominance increment values of tint (used for sepia effect)
struct rkisp1_cif_isp_cproc_config #
Configuration used by Color Processing
Definition
;
Members
c_out_range: Chrominance pixel clipping range at output. (0 for limit, 1 for full)y_in_range: Luminance pixel clipping range at output.y_out_range: Luminance pixel clipping range at output.contrast: 00~ff, 0.0~1.992brightness: 80~7F, -128~+127sat: saturation, 00~FF, 0.0~1.992hue: 80~7F, -90~+87.188
struct rkisp1_cif_isp_awb_meas_config #
Configuration for the AWB statistics
Definition
;
Members
awb_wnd: white balance measurement window (in pixels)awb_mode: the awb meas mode. From enum rkisp1_cif_isp_awb_mode_type.max_y: only pixels values < max_y contribute to awb measurement, set to 0 to disable this featuremin_y: only pixels values > min_y contribute to awb measurementmax_csum: Chrominance sum maximum value, only consider pixels with Cb+Cr, smaller than threshold for awb measurementsmin_c: Chrominance minimum value, only consider pixels with Cb/Cr each greater than threshold value for awb measurementsframes: number of frames - 1 used for mean value calculation (ucFrames=0 means 1 Frame)awb_ref_cr: reference Cr value for AWB regulation, target for AWBawb_ref_cb: reference Cb value for AWB regulation, target for AWBenable_ymax_cmp: enable Y_MAX compare (Not valid in RGB measurement mode.)
struct rkisp1_cif_isp_awb_gain_config #
Configuration used by auto white balance gain
Definition
;
Members
gain_red: gain value for red component.gain_green_r: gain value for green component in red line.gain_blue: gain value for blue component.gain_green_b: gain value for green component in blue line.
Description
All fields in this struct are 10 bit, where: 0x100h = 1, unsigned integer value, range 0 to 4 with 8 bit fractional part.
out_data_x = ( AWB_GAIN_X * in_data + 128) >> 8
struct rkisp1_cif_isp_flt_config #
Configuration used by ISP filtering
Definition
;
Members
mode: ISP_FILT_MODE register fields (from enum rkisp1_cif_isp_flt_mode)grn_stage1: Green filter stage 1 select (range 0x0...0x8)chr_h_mode: Chroma filter horizontal modechr_v_mode: Chroma filter vertical modethresh_bl0: If thresh_bl1 < sum_grad < thresh_bl0 then fac_bl0 is selected (blurring th)thresh_bl1: If sum_grad < thresh_bl1 then fac_bl1 is selected (blurring th)thresh_sh0: If thresh_sh0 < sum_grad < thresh_sh1 then thresh_sh0 is selected (sharpening th)thresh_sh1: If thresh_sh1 < sum_grad then thresh_sh1 is selected (sharpening th)lum_weight: Parameters for luminance weight function.fac_sh1: filter factor for sharp1 levelfac_sh0: filter factor for sharp0 levelfac_mid: filter factor for mid level and for static filter modefac_bl0: filter factor for blur 0 levelfac_bl1: filter factor for blur 1 level (max blur)
Description
All 4 threshold fields (thresh_) are 10 bits. All 6 factor fields (fac_) are 6 bits.
struct rkisp1_cif_isp_bdm_config #
Configuration used by Bayer DeMosaic
Definition
;
Members
demosaic_th: threshold for bayer demosaicing texture detection
struct rkisp1_cif_isp_ctk_config #
Configuration used by Cross Talk correction
Definition
;
Members
coeff: color correction matrix. Values are 11-bit signed fixed-point numbers with 4 bit integer and 7 bit fractional part, ranging from -8 (0x400) to +7.992 (0x3FF). 0 is represented by 0x000 and a coefficient value of 1 as 0x080.ct_offset: Red, Green, Blue offsets for the crosstalk correction matrix
struct rkisp1_cif_isp_goc_config #
Configuration used by Gamma Out correction
Definition
;
Members
mode: goc mode (from enum rkisp1_cif_isp_goc_mode)gamma_y: gamma out curve y-axis for all color components
Description
The number of entries of gamma_y depends on the hardware revision as is reported by the hw_revision field of the struct media_device_info that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
V10 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V10 entries, V12 has RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES_V12 entries. RKISP1_CIF_ISP_GAMMA_OUT_MAX_SAMPLES is equal to the maximum of the two.
struct rkisp1_cif_isp_hst_config #
Configuration for Histogram statistics
Definition
;
Members
mode: histogram mode (from enum rkisp1_cif_isp_histogram_mode)histogram_predivider: process every stepsize pixel, all other pixels are skippedmeas_window: coordinates of the measure windowhist_weight: weighting factor for sub-windows
Description
The number of entries of hist_weight depends on the hardware revision as is reported by the hw_revision field of the struct media_device_info that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
V10 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V10 entries, V12 has RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE_V12 entries. RKISP1_CIF_ISP_HISTOGRAM_WEIGHT_GRIDS_SIZE is equal to the maximum of the two.
struct rkisp1_cif_isp_aec_config #
Configuration for Auto Exposure statistics
Definition
;
Members
mode: Exposure measure mode (from enum rkisp1_cif_isp_exp_meas_mode)autostop: stop mode (from enum rkisp1_cif_isp_exp_ctrl_autostop)meas_window: coordinates of the measure window
struct rkisp1_cif_isp_afc_config #
Configuration for the Auto Focus statistics
Definition
;
Members
num_afm_win: max RKISP1_CIF_ISP_AFM_MAX_WINDOWSafm_win: coordinates of the meas windowthres: threshold used for minimizing the influence of noisevar_shift: the number of bits for the shift operation at the end of the calculation chain.
enum rkisp1_cif_isp_dpf_gain_usage #
dpf gain usage
Constants
RKISP1_CIF_ISP_DPF_GAIN_USAGE_DISABLED: don't use any gains in preprocessing stageRKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_GAINS: use only the noise function gains from registers DPF_NF_GAIN_R, ...RKISP1_CIF_ISP_DPF_GAIN_USAGE_LSC_GAINS: use only the gains from LSC moduleRKISP1_CIF_ISP_DPF_GAIN_USAGE_NF_LSC_GAINS: use the noise function gains and the gains from LSC moduleRKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_GAINS: use only the gains from AWB moduleRKISP1_CIF_ISP_DPF_GAIN_USAGE_AWB_LSC_GAINS: use the gains from AWB and LSC moduleRKISP1_CIF_ISP_DPF_GAIN_USAGE_MAX: upper border (only for an internal evaluation)
enum rkisp1_cif_isp_dpf_rb_filtersize #
Red and blue filter sizes
Constants
RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_13x9: red and blue filter kernel size 13x9 (means 7x5 active pixel)RKISP1_CIF_ISP_DPF_RB_FILTERSIZE_9x9: red and blue filter kernel size 9x9 (means 5x5 active pixel)
enum rkisp1_cif_isp_dpf_nll_scale_mode #
dpf noise level scale mode
Constants
RKISP1_CIF_ISP_NLL_SCALE_LINEAR: use a linear scalingRKISP1_CIF_ISP_NLL_SCALE_LOGARITHMIC: use a logarithmic scaling
struct rkisp1_cif_isp_dpf_nll #
Noise level lookup
Definition
;
Members
coeff: Noise level Lookup coefficientscale_mode: dpf noise level scale mode (from enum rkisp1_cif_isp_dpf_nll_scale_mode)
struct rkisp1_cif_isp_dpf_rb_flt #
Red blue filter config
Definition
;
Members
fltsize: The filter size for the red and blue pixels (from enum rkisp1_cif_isp_dpf_rb_filtersize)spatial_coeff: Spatial weightsr_enable: enable filter processing for red pixelsb_enable: enable filter processing for blue pixels
struct rkisp1_cif_isp_dpf_g_flt #
Green filter Configuration
Definition
;
Members
spatial_coeff: Spatial weightsgr_enable: enable filter processing for green pixels in green/red linesgb_enable: enable filter processing for green pixels in green/blue lines
struct rkisp1_cif_isp_dpf_gain #
Noise function Configuration
Definition
;
Members
mode: dpf gain usage (from enum rkisp1_cif_isp_dpf_gain_usage)nf_r_gain: Noise function Gain that replaces the AWB gain for red pixelsnf_b_gain: Noise function Gain that replaces the AWB gain for blue pixelsnf_gr_gain: Noise function Gain that replaces the AWB gain for green pixels in a red linenf_gb_gain: Noise function Gain that replaces the AWB gain for green pixels in a blue line
struct rkisp1_cif_isp_dpf_config #
Configuration used by De-noising pre-filter
Definition
;
Members
gain: noise function gaing_flt: green filter configrb_flt: red blue filter confignll: noise level lookup
struct rkisp1_cif_isp_dpf_strength_config #
strength of the filter
Definition
;
Members
r: filter strength of the RED filterg: filter strength of the GREEN filterb: filter strength of the BLUE filter
struct rkisp1_cif_isp_isp_other_cfg #
Parameters for some blocks in rockchip isp1
Definition
;
Members
dpcc_config: Defect Pixel Cluster Correction configbls_config: black level subtraction configsdg_config: sensor degamma configlsc_config: Lens Shade configawb_gain_config: Auto White balance gain configflt_config: filter configbdm_config: demosaic configctk_config: cross talk configgoc_config: gamma out configdpf_config: De-noising pre-filter configdpf_strength_config: dpf strength configcproc_config: color process configie_config: image effects config
struct rkisp1_cif_isp_isp_meas_cfg #
Rockchip ISP1 Measure Parameters
Definition
;
Members
awb_meas_config: auto white balance confighst_config: histogram configaec_config: auto exposure configafc_config: auto focus config
struct rkisp1_params_cfg #
Rockchip ISP1 Input Parameters Meta Data
Definition
;
Members
module_en_update: mask the enable bits of which module should be updatedmodule_ens: mask the enable value of each module, only update the module which correspond bit was set in module_en_updatemodule_cfg_update: mask the config bits of which module should be updatedmeas: measurement configothers: other config
struct rkisp1_cif_isp_compand_bls_config #
Rockchip ISP1 Companding parameters (BLS)
Definition
;
Members
r: Fixed subtraction value for Bayer pattern Rgr: Fixed subtraction value for Bayer pattern Grgb: Fixed subtraction value for Bayer pattern Gbb: Fixed subtraction value for Bayer pattern B
Description
The values will be subtracted from the sensor values. Note that unlike the dedicated BLS block, the BLS values in the compander are 20-bit unsigned.
struct rkisp1_cif_isp_compand_curve_config #
Rockchip ISP1 Companding parameters (expand and compression curves)
Definition
;
Members
px: Compand curve x-values. Each value stores the distance from the previous x-value, expressed as log2 of the distance on 5 bits.x: Compand curve x-values. The functionality of these parameters are unknown due to do a lack of hardware documentation, but these are left here for future compatibility purposes.y: Compand curve y-values
struct rkisp1_cif_isp_wdr_tone_curve #
Tone mapping curve definition for WDR.
Definition
;
Members
dY: the dYn increments for horizontal (input) axis of the tone curve. each 3-bit dY value represents an increment of 2**(value+3). dY[0] bits 0:2 is increment dY1, bit 3 unused dY[0] bits 4:6 is increment dY2, bit 7 unused ... dY[0] bits 28:30 is increment dY8, bit 31 unused ... and so on till dY[3] bits 28:30 is increment dY32, bit 31 unused.ym: the Ym values for the vertical (output) axis of the tone curve. each value is 13 bit.
struct rkisp1_cif_isp_wdr_iref_config #
Illumination reference config for WDR.
Definition
;
Members
rgb_factor: defines how much influence the RGBmax approach has in comparison to Y (valid values are 0..8).use_y9_8: use Y*9/8 for maximum value calculation along with the default of R, G, B for noise reduction.use_rgb7_8: decrease RGBMax by 7/8 for noise reduction.disable_transient: disable transient calculation between Y and RGBY_max.
Description
Use illumination reference value as described below, instead of only the luminance (Y) value for tone mapping and gain calculations: IRef = (rgb_factor * RGBMax_tr + (8 - rgb_factor) * Y)/8
struct rkisp1_cif_isp_wdr_config #
Configuration for wide dynamic range.
Definition
;
Members
tone_curve: tone mapping curve.iref_config: illumination reference configuration. (when use_iref is true)rgb_offset: RGB offset value for RGB operation mode. (12 bits)luma_offset: luminance offset value for RGB operation mode. (12 bits)dmin_thresh: lower threshold for deltaMin value. (12 bits)dmin_strength: strength factor for deltaMin. (valid range is 0x00..0x10)use_rgb_colorspace: use RGB instead of luminance/chrominance colorspace.bypass_chroma_mapping: disable chrominance mapping (only valid if use_rgb_colorspace = 0)use_iref: use illumination reference instead of Y for tone mapping and gain calculations.
struct rkisp1_cif_isp_awb_meas #
AWB measured values
Definition
;
Members
cnt: White pixel count, number of "white pixels" found during last measurementmean_y_or_g: Mean value of Y within window and frames, Green if RGB is selected.mean_cb_or_b: Mean value of Cb within window and frames, Blue if RGB is selected.mean_cr_or_r: Mean value of Cr within window and frames, Red if RGB is selected.
struct rkisp1_cif_isp_awb_stat #
statistics automatic white balance data
Definition
;
Members
awb_mean: Mean measured data
struct rkisp1_cif_isp_bls_meas_val #
BLS measured values
Definition
;
Members
meas_r: Mean measured value for Bayer pattern Rmeas_gr: Mean measured value for Bayer pattern Grmeas_gb: Mean measured value for Bayer pattern Gbmeas_b: Mean measured value for Bayer pattern B
struct rkisp1_cif_isp_ae_stat #
statistics auto exposure data
Definition
;
Members
exp_mean: Mean luminance value of block xxbls_val: BLS measured values
Description
The number of entries of exp_mean depends on the hardware revision as is reported by the hw_revision field of the struct media_device_info that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
V10 has RKISP1_CIF_ISP_AE_MEAN_MAX_V10 entries, V12 has RKISP1_CIF_ISP_AE_MEAN_MAX_V12 entries. RKISP1_CIF_ISP_AE_MEAN_MAX is equal to the maximum of the two.
Image is divided into 5x5 blocks on V10 and 9x9 blocks on V12.
struct rkisp1_cif_isp_af_meas_val #
AF measured values
Definition
;
Members
sum: sharpness valuelum: luminance value
struct rkisp1_cif_isp_af_stat #
statistics auto focus data
Definition
;
Members
window: AF measured value of window x
Description
The module measures the sharpness in 3 windows of selectable size via register settings(ISP_AFM_*_A/B/C)
struct rkisp1_cif_isp_hist_stat #
statistics histogram data
Definition
;
Members
hist_bins: measured bin counters. Each bin is a 20 bits unsigned fixed point type. Bits 0-4 are the fractional part and bits 5-19 are the integer part.
Description
The window of the measurements area is divided to 5x5 sub-windows for V10 and to 9x9 sub-windows for V12. The histogram is then computed for each sub-window independently and the final result is a weighted average of the histogram measurements on all sub-windows. The window of the measurements area and the weight of each sub-window are configurable using struct rkisp1_cif_isp_hst_config.
The histogram contains 16 bins in V10 and 32 bins in V12.
The number of entries of hist_bins depends on the hardware revision as is reported by the hw_revision field of the struct media_device_info that is returned by ioctl MEDIA_IOC_DEVICE_INFO.
V10 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V10 entries, V12 has RKISP1_CIF_ISP_HIST_BIN_N_MAX_V12 entries. RKISP1_CIF_ISP_HIST_BIN_N_MAX is equal to the maximum of the two.
struct rkisp1_cif_isp_stat #
Rockchip ISP1 Statistics Data
Definition
;
Members
awb: statistics data for automatic white balanceae: statistics data for auto exposureaf: statistics data for auto focushist: statistics histogram data
struct rkisp1_stat_buffer #
Rockchip ISP1 Statistics Meta Data
Definition
;
Members
meas_type: measurement types (RKISP1_CIF_ISP_STAT_* definitions)frame_id: frame ID for syncparams: statistics data
enum rkisp1_ext_params_block_type #
RkISP1 extensible params block type
Constants
RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS: Black level subtractionRKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC: Defect pixel cluster correctionRKISP1_EXT_PARAMS_BLOCK_TYPE_SDG: Sensor de-gammaRKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN: Auto white balance gainsRKISP1_EXT_PARAMS_BLOCK_TYPE_FLT: ISP filteringRKISP1_EXT_PARAMS_BLOCK_TYPE_BDM: Bayer de-mosaicRKISP1_EXT_PARAMS_BLOCK_TYPE_CTK: Cross-talk correctionRKISP1_EXT_PARAMS_BLOCK_TYPE_GOC: Gamma out correctionRKISP1_EXT_PARAMS_BLOCK_TYPE_DPF: De-noise pre-filterRKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH: De-noise pre-filter strengthRKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC: Color processingRKISP1_EXT_PARAMS_BLOCK_TYPE_IE: Image effectsRKISP1_EXT_PARAMS_BLOCK_TYPE_LSC: Lens shading correctionRKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS: Auto white balance statisticsRKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS: Histogram statisticsRKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS: Auto exposure statisticsRKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS: Auto-focus statisticsRKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS: BLS in the compand blockRKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND: Companding expand curveRKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS: Companding compress curveRKISP1_EXT_PARAMS_BLOCK_TYPE_WDR: Wide dynamic range
rkisp1_ext_params_block_header #
rkisp1_ext_params_block_header
RkISP1 extensible parameters block header
Description
This structure represents the common part of all the ISP configuration
blocks and is identical to v4l2_isp_params_block_header.
The type field is one of the values enumerated by
rkisp1_ext_params_block_type and specifies how the data should be
interpreted by the driver.
The flags field is a bitmask of per-block flags RKISP1_EXT_PARAMS_FL_*.
struct rkisp1_ext_params_bls_config #
RkISP1 extensible params BLS config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Black Level Subtraction configuration, seerkisp1_cif_isp_bls_config
Description
RkISP1 extensible parameters Black Level Subtraction configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS.
struct rkisp1_ext_params_dpcc_config #
RkISP1 extensible params DPCC config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Defective Pixel Cluster Correction configuration, seerkisp1_cif_isp_dpcc_config
Description
RkISP1 extensible parameters Defective Pixel Cluster Correction configuration
block. Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC.
struct rkisp1_ext_params_sdg_config #
RkISP1 extensible params SDG config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Sensor Degamma configuration, seerkisp1_cif_isp_sdg_config
Description
RkISP1 extensible parameters Sensor Degamma configuration block. Identified
by RKISP1_EXT_PARAMS_BLOCK_TYPE_SDG.
struct rkisp1_ext_params_lsc_config #
RkISP1 extensible params LSC config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Lens Shading Correction configuration, seerkisp1_cif_isp_lsc_config
Description
RkISP1 extensible parameters Lens Shading Correction configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_LSC.
struct rkisp1_ext_params_awb_gain_config #
RkISP1 extensible params AWB gain config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Auto-White Balance Gains configuration, seerkisp1_cif_isp_awb_gain_config
Description
RkISP1 extensible parameters Auto-White Balance Gains configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_GAIN.
struct rkisp1_ext_params_flt_config #
RkISP1 extensible params FLT config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Filter configuration, seerkisp1_cif_isp_flt_config
Description
RkISP1 extensible parameters Filter configuration block. Identified by
RKISP1_EXT_PARAMS_BLOCK_TYPE_FLT.
struct rkisp1_ext_params_bdm_config #
RkISP1 extensible params BDM config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Demosaicing configuration, seerkisp1_cif_isp_bdm_config
Description
RkISP1 extensible parameters Demosaicing configuration block. Identified by
RKISP1_EXT_PARAMS_BLOCK_TYPE_BDM.
struct rkisp1_ext_params_ctk_config #
RkISP1 extensible params CTK config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Cross-Talk configuration, seerkisp1_cif_isp_ctk_config
Description
RkISP1 extensible parameters Cross-Talk configuration block. Identified by
RKISP1_EXT_PARAMS_BLOCK_TYPE_CTK.
struct rkisp1_ext_params_goc_config #
RkISP1 extensible params GOC config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Gamma-Out configuration, seerkisp1_cif_isp_goc_config
Description
RkISP1 extensible parameters Gamma-Out configuration block. Identified by
RKISP1_EXT_PARAMS_BLOCK_TYPE_GOC.
struct rkisp1_ext_params_dpf_config #
RkISP1 extensible params DPF config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: De-noise Pre-Filter configuration, seerkisp1_cif_isp_dpf_config
Description
RkISP1 extensible parameters De-noise Pre-Filter configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF.
struct rkisp1_ext_params_dpf_strength_config #
RkISP1 extensible params DPF strength config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: De-noise Pre-Filter strength configuration, seerkisp1_cif_isp_dpf_strength_config
Description
RkISP1 extensible parameters De-noise Pre-Filter strength configuration
block. Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_DPF_STRENGTH.
struct rkisp1_ext_params_cproc_config #
RkISP1 extensible params CPROC config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Color processing configuration, seerkisp1_cif_isp_cproc_config
Description
RkISP1 extensible parameters Color Processing configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_CPROC.
struct rkisp1_ext_params_ie_config #
RkISP1 extensible params IE config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Image Effect configuration, seerkisp1_cif_isp_ie_config
Description
RkISP1 extensible parameters Image Effect configuration block. Identified by
RKISP1_EXT_PARAMS_BLOCK_TYPE_IE.
struct rkisp1_ext_params_awb_meas_config #
RkISP1 extensible params AWB Meas config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Auto-White Balance measure configuration, seerkisp1_cif_isp_awb_meas_config
Description
RkISP1 extensible parameters Auto-White Balance Measurement configuration
block. Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_AWB_MEAS.
struct rkisp1_ext_params_hst_config #
RkISP1 extensible params Histogram config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Histogram statistics configuration, seerkisp1_cif_isp_hst_config
Description
RkISP1 extensible parameters Histogram statistics configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_HST_MEAS.
struct rkisp1_ext_params_aec_config #
RkISP1 extensible params AEC config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Auto-Exposure statistics configuration, seerkisp1_cif_isp_aec_config
Description
RkISP1 extensible parameters Auto-Exposure statistics configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_AEC_MEAS.
struct rkisp1_ext_params_afc_config #
RkISP1 extensible params AFC config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Auto-Focus statistics configuration, seerkisp1_cif_isp_afc_config
Description
RkISP1 extensible parameters Auto-Focus statistics configuration block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_AFC_MEAS.
struct rkisp1_ext_params_compand_bls_config #
RkISP1 extensible params Compand BLS config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Companding BLS configuration, seerkisp1_cif_isp_compand_bls_config
Description
RkISP1 extensible parameters Companding configuration block (black level
subtraction). Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_BLS.
struct rkisp1_ext_params_compand_curve_config #
RkISP1 extensible params Compand curve config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: Companding curve configuration, seerkisp1_cif_isp_compand_curve_config
Description
RkISP1 extensible parameters Companding configuration block (expand and
compression curves). Identified by
RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_EXPAND or
RKISP1_EXT_PARAMS_BLOCK_TYPE_COMPAND_COMPRESS.
struct rkisp1_ext_params_wdr_config #
RkISP1 extensible params Wide dynamic range config
Definition
;
Members
header: The RkISP1 extensible parameters header, seerkisp1_ext_params_block_headerconfig: WDR configuration, seerkisp1_cif_isp_wdr_config
Description
RkISP1 extensible parameters WDR block.
Identified by RKISP1_EXT_PARAMS_BLOCK_TYPE_WDR
enum rksip1_ext_param_buffer_version #
RkISP1 extensible parameters version
Constants
RKISP1_EXT_PARAM_BUFFER_V1: First version of RkISP1 extensible parameters
struct rkisp1_ext_params_cfg #
RkISP1 extensible parameters configuration
Definition
;
Members
version: The RkISP1 extensible parameters buffer version, seerksip1_ext_param_buffer_versiondata_size: The RkISP1 configuration data effective size, excluding this headerdata: The RkISP1 extensible configuration data blocks
Description
This is the driver-specific implementation of
v4l2_isp_params_buffer.
Currently the single RKISP1_EXT_PARAM_BUFFER_V1 version is supported. When a new format version will be added, a mechanism for userspace to query the supported format versions will be implemented in the form of a read-only V4L2 control. If such control is not available, userspace should assume only RKISP1_EXT_PARAM_BUFFER_V1 is supported by the driver.
The read-only V4L2 control RKISP1_CID_SUPPORTED_PARAMS_BLOCKS can be used
to query the blocks supported by the device. It contains a bitmask where each
bit represents the availability of the corresponding entry from the
rkisp1_ext_params_block_type enum. The current and default values
of the control represents the blocks supported by the device instance, while
the maximum value represents the blocks supported by the kernel driver,
independently of the device instance.
The expected memory layout of the parameters buffer is:
+-------------------- struct rkisp1_ext_params_cfg -------------------+
| version = RKISP1_EXT_PARAM_BUFFER_V1; |
| data_size = sizeof(struct rkisp1_ext_params_bls_config) |
| + sizeof(struct rkisp1_ext_params_dpcc_config); |
| +------------------------- data ---------------------------------+ |
| | +------------- struct rkisp1_ext_params_bls_config -----------+ | |
| | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
| | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_BLS; | | | |
| | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
| | | | size = sizeof(struct rkisp1_ext_params_bls_config); | | | |
| | | +---------------------------------------------------------+ | | |
| | | +---------- struct rkisp1_cif_isp_bls_config -------------+ | | |
| | | | enable_auto = 0; | | | |
| | | | fixed_val.r = 256; | | | |
| | | | fixed_val.gr = 256; | | | |
| | | | fixed_val.gb = 256; | | | |
| | | | fixed_val.b = 256; | | | |
| | | +---------------------------------------------------------+ | | |
| | +------------ struct rkisp1_ext_params_dpcc_config -----------+ | |
| | | +-------- struct rkisp1_ext_params_block_header ---------+ | | |
| | | | type = RKISP1_EXT_PARAMS_BLOCK_TYPE_DPCC; | | | |
| | | | flags = RKISP1_EXT_PARAMS_FL_BLOCK_ENABLE; | | | |
| | | | size = sizeof(struct rkisp1_ext_params_dpcc_config); | | | |
| | | +---------------------------------------------------------+ | | |
| | | +---------- struct rkisp1_cif_isp_dpcc_config ------------+ | | |
| | | | mode = RKISP1_CIF_ISP_DPCC_MODE_STAGE1_ENABLE; | | | |
| | | | output_mode = | | | |
| | | | RKISP1_CIF_ISP_DPCC_OUTPUT_MODE_STAGE1_INCL_G_CENTER; | | | |
| | | | set_use = ... ; | | | |
| | | | ... = ... ; | | | |
| | | +---------------------------------------------------------+ | | |
| | +-------------------------------------------------------------+ | |
| +-----------------------------------------------------------------+ |
+---------------------------------------------------------------------+
V4L2_META_FMT_UVC_MSXU_1_5 ('UVCM')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Microsoft(R)'s UVC Payload Metadata.
Description #
V4L2_META_FMT_UVC_MSXU_1_5 buffers follow the metadata buffer layout of V4L2_META_FMT_UVC with the only difference that it includes all the UVC metadata in the buffer[] field, not just the first 2-12 bytes.
The metadata format follows the specification from Microsoft(R) [1].
[1] https://docs.microsoft.com/en-us/windows-hardware/drivers/stream/uvc-extensions-1-5
V4L2_META_FMT_UVC ('UVCH')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
UVC Payload Header Data
Description #
This format describes standard UVC metadata, extracted from UVC packet headers and provided by the UVC driver through metadata video nodes. That data includes exact copies of the standard part of UVC Payload Header contents and auxiliary timing information, required for precise interpretation of timestamps, contained in those headers. See section "2.4.3.3 Video and Still Image Payload Headers" of the "UVC 1.5 Class specification" for details.
Each UVC payload header can be between 2 and 12 bytes large. Buffers can contain multiple headers, if multiple such headers have been transmitted by the camera for the respective frame. However, the driver may drop headers when the buffer is full, when they contain no useful information (e.g. those without the SCR field or with that field identical to the previous header), or generally to perform rate limiting when the device sends a large number of headers.
Each individual block contains the following fields:
|
Field |
Description |
|---|---|
|
__u64 ts; |
system timestamp in host byte order, measured by the driver upon reception of the payload |
|
__u16 sof; |
USB Frame Number in host byte order, also obtained by the driver as close as possible to the above timestamp to enable correlation between them |
|
The rest is an exact copy of the UVC payload header: |
|
|
__u8 length; |
length of the rest of the block, including this field. Please note that regardless of this value, for V4L2_META_FMT_UVC the kernel will never copy more than 2-12 bytes. |
|
__u8 flags; |
Flags, indicating presence of other standard UVC fields |
|
__u8 buf[]; |
The rest of the header, possibly including UVC PTS and SCR fields |
V4L2_META_FMT_VIVID ('VIVD')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
VIVID Metadata Format
Description #
This describes metadata format used by the vivid driver.
It sets Brightness, Saturation, Contrast and Hue, each of which maps to corresponding controls of the vivid driver with respect to the range and default values.
It contains the following fields:
|
Field |
Description |
|---|---|
|
u16 brightness; |
Image brightness, the value is in the range 0 to 255, with the default value as 128. |
|
u16 contrast; |
Image contrast, the value is in the range 0 to 255, with the default value as 128. |
|
u16 saturation; |
Image color saturation, the value is in the range 0 to 255, with the default value as 128. |
|
s16 hue; |
Image color balance, the value is in the range -128 to 128, with the default value as 0. |
V4L2_META_FMT_VSP1_HGO ('VSPH')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Renesas R-Car VSP1 1-D Histogram Data
Description #
This format describes histogram data generated by the Renesas R-Car VSP1 1-D Histogram (HGO) engine.
The VSP1 HGO is a histogram computation engine that can operate on RGB, YCrCb or HSV data. It operates on a possibly cropped and subsampled input image and computes the minimum, maximum and sum of all pixels as well as per-channel histograms.
The HGO can compute histograms independently per channel, on the maximum of the three channels (RGB data only) or on the Y channel only (YCbCr only). It can additionally output the histogram with 64 or 256 bins, resulting in four possible modes of operation.
-
In 64 bins normal mode, the HGO operates on the three channels independently to compute three 64-bins histograms. RGB, YCbCr and HSV image formats are supported.
-
In 64 bins maximum mode, the HGO operates on the maximum of the (R, G, B) channels to compute a single 64-bins histogram. Only the RGB image format is supported.
-
In 256 bins normal mode, the HGO operates on the Y channel to compute a single 256-bins histogram. Only the YCbCr image format is supported.
-
In 256 bins maximum mode, the HGO operates on the maximum of the (R, G, B) channels to compute a single 256-bins histogram. Only the RGB image format is supported.
Byte Order. All data is stored in memory in little endian format. Each cell in the tables contains one byte.
|
Offset |
Memory |
||||
|---|---|---|---|---|---|
|
[31:24] |
[23:16] |
[15:8] |
[7:0] |
||
|
0 |
R/Cr/H max [7:0] |
R/Cr/H min [7:0] |
|||
|
4 |
G/Y/S max [7:0] |
G/Y/S min [7:0] |
|||
|
8 |
B/Cb/V max [7:0] |
B/Cb/V min [7:0] |
|||
|
12 |
R/Cr/H sum [31:0] |
||||
|
16 |
G/Y/S sum [31:0] |
||||
|
20 |
B/Cb/V sum [31:0] |
||||
|
24 |
R/Cr/H bin 0 [31:0] |
||||
|
... |
|||||
|
276 |
R/Cr/H bin 63 [31:0] |
||||
|
280 |
G/Y/S bin 0 [31:0] |
||||
|
... |
|||||
|
532 |
G/Y/S bin 63 [31:0] |
||||
|
536 |
B/Cb/V bin 0 [31:0] |
||||
|
... |
|||||
|
788 |
B/Cb/V bin 63 [31:0] |
||||
|
Offset |
Memory |
||||
|---|---|---|---|---|---|
|
[31:24] |
[23:16] |
[15:8] |
[7:0] |
||
|
0 |
max(R,G,B) max [7:0] |
max(R,G,B) min [7:0] |
|||
|
4 |
max(R,G,B) sum [31:0] |
||||
|
8 |
max(R,G,B) bin 0 [31:0] |
||||
|
... |
|||||
|
260 |
max(R,G,B) bin 63 [31:0] |
||||
|
Offset |
Memory |
||||
|---|---|---|---|---|---|
|
[31:24] |
[23:16] |
[15:8] |
[7:0] |
||
|
0 |
Y max [7:0] |
Y min [7:0] |
|||
|
4 |
Y sum [31:0] |
||||
|
8 |
Y bin 0 [31:0] |
||||
|
... |
|||||
|
1028 |
Y bin 255 [31:0] |
||||
|
Offset |
Memory |
||||
|---|---|---|---|---|---|
|
[31:24] |
[23:16] |
[15:8] |
[7:0] |
||
|
0 |
max(R,G,B) max [7:0] |
max(R,G,B) min [7:0] |
|||
|
4 |
max(R,G,B) sum [31:0] |
||||
|
8 |
max(R,G,B) bin 0 [31:0] |
||||
|
... |
|||||
|
1028 |
max(R,G,B) bin 255 [31:0] |
||||
V4L2_META_FMT_VSP1_HGT ('VSPT')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Renesas R-Car VSP1 2-D Histogram Data
Description #
This format describes histogram data generated by the Renesas R-Car VSP1 2-D Histogram (HGT) engine.
The VSP1 HGT is a histogram computation engine that operates on HSV data. It operates on a possibly cropped and subsampled input image and computes the sum, maximum and minimum of the S component as well as a weighted frequency histogram based on the H and S components.
The histogram is a matrix of 6 Hue and 32 Saturation buckets, 192 in total. Each HSV value is added to one or more buckets with a weight between 1 and 16 depending on the Hue areas configuration. Finding the corresponding buckets is done by inspecting the H and S value independently.
The Saturation position n (0 - 31) of the bucket in the matrix is found by the expression:
n = S / 8
The Hue position m (0 - 5) of the bucket in the matrix depends on how the HGT Hue areas are configured. There are 6 user configurable Hue Areas which can be configured to cover overlapping Hue values:
Area 0 Area 1 Area 2 Area 3 Area 4 Area 5
________ ________ ________ ________ ________ ________
\ /| |\ /| |\ /| |\ /| |\ /| |\ /| |\ /
\ / | | \ / | | \ / | | \ / | | \ / | | \ / | | \ /
X | | X | | X | | X | | X | | X | | X
/ \ | | / \ | | / \ | | / \ | | / \ | | / \ | | / \
/ \| |/ \| |/ \| |/ \| |/ \| |/ \| |/ \
5U 0L 0U 1L 1U 2L 2U 3L 3U 4L 4U 5L 5U 0L
<0..............................Hue Value............................255>
When two consecutive areas don't overlap (n+1L is equal to nU) the boundary value is considered as part of the lower area.
Pixels with a hue value included in the centre of an area (between nL and nU included) are attributed to that single area and given a weight of 16. Pixels with a hue value included in the overlapping region between two areas (between n+1L and nU excluded) are attributed to both areas and given a weight for each of these areas proportional to their position along the diagonal lines (rounded down).
The Hue area setup must match one of the following constrains:
0L <= 0U <= 1L <= 1U <= 2L <= 2U <= 3L <= 3U <= 4L <= 4U <= 5L <= 5U
0U <= 1L <= 1U <= 2L <= 2U <= 3L <= 3U <= 4L <= 4U <= 5L <= 5U <= 0L
Byte Order. All data is stored in memory in little endian format. Each cell in the tables contains one byte.
|
Offset |
Memory |
||||
|---|---|---|---|---|---|
|
[31:24] |
[23:16] |
[15:8] |
[7:0] |
||
|
0 |
|
S max [7:0] |
|
S min [7:0] |
|
|
4 |
S sum [31:0] |
||||
|
8 |
Histogram bucket (m=0, n=0) [31:0] |
||||
|
12 |
Histogram bucket (m=0, n=1) [31:0] |
||||
|
... |
|||||
|
132 |
Histogram bucket (m=0, n=31) [31:0] |
||||
|
136 |
Histogram bucket (m=1, n=0) [31:0] |
||||
|
... |
|||||
|
264 |
Histogram bucket (m=2, n=0) [31:0] |
||||
|
... |
|||||
|
392 |
Histogram bucket (m=3, n=0) [31:0] |
||||
|
... |
|||||
|
520 |
Histogram bucket (m=4, n=0) [31:0] |
||||
|
... |
|||||
|
648 |
Histogram bucket (m=5, n=0) [31:0] |
||||
|
... |
|||||
|
772 |
Histogram bucket (m=5, n=31) [31:0] |
||||
Streaming I/O (Memory Mapping)
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Input and output devices support this I/O method when the V4L2_CAP_STREAMING flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl is set. There are two streaming methods, to determine if the memory mapping flavor is supported applications must call the vidioc_reqbufs ioctl with the memory type set to V4L2_MEMORY_MMAP.
Streaming is an I/O method where only pointers to buffers are exchanged between application and driver, the data itself is not copied. Memory mapping is primarily intended to map buffers in device memory into the application's address space. Device memory can be for example the video memory on a graphics card with a video capture add-on. However, being the most efficient I/O method available for a long time, many other drivers support streaming as well, allocating buffers in DMA-able main memory.
A driver can support many sets of buffers. Each set is identified by a unique buffer type value. The sets are independent and each set can hold a different type of data. To access different sets at the same time different file descriptors must be used. 1
To allocate device buffers applications call the vidioc_reqbufs ioctl with the desired number of buffers and buffer type, for example V4L2_BUF_TYPE_VIDEO_CAPTURE. This ioctl can also be used to change the number of buffers or to free the allocated memory, provided none of the buffers are still mapped.
Before applications can access the buffers they must map them into their address space with the mmap() function. The location of the buffers in device memory can be determined with the ioctl VIDIOC_QUERYBUF ioctl. In the single-planar API case, the m.offset and length returned in a struct v4l2_buffer are passed as sixth and second parameter to the mmap() function. When using the multi-planar API, struct v4l2_buffer contains an array of struct v4l2_plane structures, each containing its own m.offset and length. When using the multi-planar API, every plane of every buffer has to be mapped separately, so the number of calls to mmap() should be equal to number of buffers times number of planes in each buffer. The offset and length values must not be modified. Remember, the buffers are allocated in physical memory, as opposed to virtual memory, which can be swapped out to disk. Applications should free the buffers as soon as possible with the munmap() function.
Example: Mapping buffers in the single-planar API #
struct v4l2_requestbuffers reqbuf;
*buffers;
unsigned int i;
;
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
reqbuf.memory = V4L2_MEMORY_MMAP;
reqbuf.count = 20;
if
/* We want at least five buffers. */
if
buffers = ;
;
for
/* Cleanup. */
for
;
Example: Mapping buffers in the multi-planar API #
struct v4l2_requestbuffers reqbuf;
/* Our current format uses 3 planes per buffer */
*buffers;
unsigned int i, j;
;
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
reqbuf.memory = V4L2_MEMORY_MMAP;
reqbuf.count = 20;
if
/* We want at least five buffers. */
if
buffers = ;
;
for
/* Cleanup. */
for
for
;
Conceptually streaming drivers maintain two buffer queues, an incoming and an outgoing queue. They separate the synchronous capture or output operation locked to a video clock from the application which is subject to random disk or network delays and preemption by other processes, thereby reducing the probability of data loss. The queues are organized as FIFOs, buffers will be output in the order enqueued in the incoming FIFO, and were captured in the order dequeued from the outgoing FIFO.
The driver may require a minimum number of buffers enqueued at all times to function, apart of this no limit exists on the number of buffers applications can enqueue in advance, or dequeue and process. They can also enqueue in a different order than buffers have been dequeued, and the driver can fill enqueued empty buffers in any order. 2 The index number of a buffer (struct v4l2_buffer index) plays no role here, it only identifies the buffer.
Initially all mapped buffers are in dequeued state, inaccessible by the driver. For capturing applications it is customary to first enqueue all mapped buffers, then to start capturing and enter the read loop. Here the application waits until a filled buffer can be dequeued, and re-enqueues the buffer when the data is no longer needed. Output applications fill and enqueue buffers, when enough buffers are stacked up the output is started with VIDIOC_STREAMON. In the write loop, when the application runs out of free buffers, it must wait until an empty buffer can be dequeued and reused.
To enqueue and dequeue a buffer applications use the VIDIOC_QBUF and VIDIOC_DQBUF ioctl. The status of a buffer being mapped, enqueued, full or empty can be determined at any time using the ioctl VIDIOC_QUERYBUF ioctl. Two methods exist to suspend execution of the application until one or more buffers can be dequeued. By default VIDIOC_DQBUF blocks when no buffer is in the outgoing queue. When the O_NONBLOCK flag was given to the open() function, VIDIOC_DQBUF returns immediately with an EAGAIN error code when no buffer is available. The select() or poll() functions are always available.
To start and stop capturing or output applications call the VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctl.
Drivers implementing memory mapping I/O must support the VIDIOC_REQBUFS, VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctls, the mmap(), munmap(), select() and poll() function. 3
[capture example]
[1] One could use one file descriptor and set the buffer type field accordingly when calling ioctl VIDIOC_QBUF, VIDIOC_DQBUF etc., but it makes the select() function ambiguous. We also like the clean approach of one file descriptor per logical stream. Video overlay for example is also a logical stream, although the CPU is not needed for continuous operation.
[2] Random enqueue order permits applications processing images out of order (such as video codecs) to return buffers earlier, reducing the probability of data loss. Random fill order allows drivers to reuse buffers on a LIFO-basis, taking advantage of caches holding scatter-gather lists and the like.
[3] At the driver level select() and poll() are the same, and select() is too important to be optional. The rest should be evident.
Opening and Closing Devices
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Controlling a hardware peripheral via V4L2 #
Hardware that is supported using the V4L2 uAPI often consists of multiple devices or peripherals, each of which have their own driver.
The bridge driver exposes one or more V4L2 device nodes (see V4L2 Device Node Naming).
There are other drivers providing support for other components of the hardware, which may also expose device nodes, called V4L2 sub-devices.
When such V4L2 sub-devices are exposed, they allow controlling those other hardware components - usually connected via a serial bus (like I²C, SMBus or SPI). Depending on the bridge driver, those sub-devices can be controlled indirectly via the bridge driver or explicitly via the Media Controller and via the V4L2 sub-devices.
The devices that require the use of the Media Controller are called MC-centric devices. The devices that are fully controlled via V4L2 device nodes are called video-node-centric.
Userspace can check if a V4L2 hardware peripheral is MC-centric by calling ioctl VIDIOC_QUERYCAP and checking the device_caps field.
If the device returns V4L2_CAP_IO_MC flag at device_caps, then it is MC-centric, otherwise, it is video-node-centric.
It is required for MC-centric drivers to identify the V4L2 sub-devices and to configure the pipelines via the media controller API before using the peripheral. Also, the sub-devices' configuration shall be controlled via the sub-device API.
V4L2 Device Node Naming #
V4L2 drivers are implemented as kernel modules, loaded manually by the system administrator or automatically when a device is first discovered. The driver modules plug into the videodev kernel module. It provides helper functions and a common application interface specified in this document.
Each driver thus loaded registers one or more device nodes with major number 81. Minor numbers are allocated dynamically unless the kernel is compiled with the kernel option CONFIG_VIDEO_FIXED_MINOR_RANGES. In that case minor numbers are allocated in ranges depending on the device node type.
The device nodes supported by the Video4Linux subsystem are:
|
Default device node name |
Usage |
|---|---|
|
|
Video and metadata for capture/output devices |
|
|
Vertical blank data (i.e. closed captions, teletext) |
|
|
Radio tuners and modulators |
|
|
Software Defined Radio tuners and modulators |
|
|
Touch sensors |
|
|
Video sub-devices (used by sensors and other components of the hardware peripheral)1 |
Where X is a non-negative integer.
[1] V4L2 sub-device nodes (e. g. /dev/v4l-subdevX) use a different set of system calls, as covered at subdev.
Many drivers support "video_nr", "radio_nr" or "vbi_nr" module options to select specific video/radio/vbi node numbers. This allows the user to request that the device node is named e.g. /dev/video5 instead of leaving it to chance. When the driver supports multiple devices of the same type more than one device node number can be assigned, separated by commas:
# modprobe mydriver video_nr=0,1 radio_nr=0,1
In /etc/modules.conf this may be written as:
options mydriver video_nr=0,1 radio_nr=0,1
When no device node number is given as module option the driver supplies a default.
Normally udev will create the device nodes in /dev automatically for you. If udev is not installed, then you need to enable the CONFIG_VIDEO_FIXED_MINOR_RANGES kernel option in order to be able to correctly relate a minor number to a device node number. I.e., you need to be certain that minor number 5 maps to device node name video5. With this kernel option different device types have different minor number ranges. These ranges are listed in Interfaces.
The creation of character special files (with mknod) is a privileged operation and devices cannot be opened by major and minor number. That means applications cannot reliably scan for loaded or installed drivers. The user must enter a device name, or the application can try the conventional device names.
Related Devices #
Devices can support several functions. For example video capturing, VBI capturing and radio support.
The V4L2 API creates different V4L2 device nodes for each of these functions.
The V4L2 API was designed with the idea that one device node could support all functions. However, in practice this never worked: this 'feature' was never used by applications and many drivers did not support it and if they did it was certainly never tested. In addition, switching a device node between different functions only works when using the streaming I/O API, not with the read()/write() API.
Today each V4L2 device node supports just one function.
Besides video input or output the hardware may also support audio sampling or playback. If so, these functions are implemented as ALSA PCM devices with optional ALSA audio mixer devices.
One problem with all these devices is that the V4L2 API makes no provisions to find these related V4L2 device nodes. Some really complex hardware use the Media Controller (see Part IV - Media Controller API) which can be used for this purpose. But several drivers do not use it, and while some code exists that uses sysfs to discover related V4L2 device nodes (see libmedia_dev in the v4l-utils git repository), there is no library yet that can provide a single API towards both Media Controller-based devices and devices that do not use the Media Controller. If you want to work on this please write to the linux-media mailing list: https://linuxtv.org/lists.php.
Multiple Opens #
V4L2 devices can be opened more than once. 2 When this is supported by the driver, users can for example start a "panel" application to change controls like brightness or audio volume, while another application captures video and audio. In other words, panel applications are comparable to an ALSA audio mixer application. Just opening a V4L2 device should not change the state of the device. 3
Once an application has allocated the memory buffers needed for streaming data (by calling the vidioc_reqbufs or ioctl VIDIOC_CREATE_BUFS ioctls, or implicitly by calling the read() or write() functions) that application (filehandle) becomes the owner of the device. It is no longer allowed to make changes that would affect the buffer sizes (e.g. by calling the VIDIOC_S_FMT ioctl) and other applications are no longer allowed to allocate buffers or start or stop streaming. The EBUSY error code will be returned instead.
Merely opening a V4L2 device does not grant exclusive access. 4 Initiating data exchange however assigns the right to read or write the requested type of data, and to change related properties, to this file descriptor. Applications can request additional access privileges using the priority mechanism described in Application Priority.
Shared Data Streams #
V4L2 drivers should not support multiple applications reading or writing the same data stream on a device by copying buffers, time multiplexing or similar means. This is better handled by a proxy application in user space.
Functions #
To open and close V4L2 devices applications use the open() and close() function, respectively. Devices are programmed using the ioctl() function as explained in the following sections.
[2] There are still some old and obscure drivers that have not been updated to allow for multiple opens. This implies that for such drivers open() can return an EBUSY error code when the device is already in use.
[3] Unfortunately, opening a radio device often switches the state of the device to radio mode in many drivers. This behavior should be fixed eventually as it violates the V4L2 specification.
[4] Drivers could recognize the O_EXCL open flag. Presently this is not required, so applications cannot know if it really works.
Raw Bayer Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Description #
The raw Bayer formats are used by image sensors before much if any processing is performed on the image. The formats contain green, red and blue components, with alternating lines of red and green, and blue and green pixels in different orders. See also the Wikipedia article on Bayer filter.
- V4L2_PIX_FMT_RAW_CRU10 ('CR10'), V4L2_PIX_FMT_RAW_CRU12 ('CR12'), V4L2_PIX_FMT_RAW_CRU14 ('CR14'), V4L2_PIX_FMT_RAW_CRU20 ('CR20')
- V4L2_PIX_FMT_SRGGB8 ('RGGB'), V4L2_PIX_FMT_SGRBG8 ('GRBG'), V4L2_PIX_FMT_SGBRG8 ('GBRG'), V4L2_PIX_FMT_SBGGR8 ('BA81'),
- V4L2_PIX_FMT_PISP_COMP1_RGGB ('PC1R'), V4L2_PIX_FMT_PISP_COMP1_GRBG ('PC1G'), V4L2_PIX_FMT_PISP_COMP1_GBRG ('PC1g'), V4L2_PIX_FMT_PISP_COMP1_BGGR ('PC1B), V4L2_PIX_FMT_PISP_COMP1_MONO ('PC1M'), V4L2_PIX_FMT_PISP_COMP2_RGGB ('PC2R'), V4L2_PIX_FMT_PISP_COMP2_GRBG ('PC2G'), V4L2_PIX_FMT_PISP_COMP2_GBRG ('PC2g'), V4L2_PIX_FMT_PISP_COMP2_BGGR ('PC2B), V4L2_PIX_FMT_PISP_COMP2_MONO ('PC2M')
- V4L2_PIX_FMT_SRGGB10 ('RG10'), V4L2_PIX_FMT_SGRBG10 ('BA10'), V4L2_PIX_FMT_SGBRG10 ('GB10'), V4L2_PIX_FMT_SBGGR10 ('BG10'),
- V4L2_PIX_FMT_SRGGB10P ('pRAA'), V4L2_PIX_FMT_SGRBG10P ('pgAA'), V4L2_PIX_FMT_SGBRG10P ('pGAA'), V4L2_PIX_FMT_SBGGR10P ('pBAA'),
- V4L2_PIX_FMT_SBGGR10ALAW8 ('aBA8'), V4L2_PIX_FMT_SGBRG10ALAW8 ('aGA8'), V4L2_PIX_FMT_SGRBG10ALAW8 ('agA8'), V4L2_PIX_FMT_SRGGB10ALAW8 ('aRA8'),
- V4L2_PIX_FMT_SBGGR10DPCM8 ('bBA8'), V4L2_PIX_FMT_SGBRG10DPCM8 ('bGA8'), V4L2_PIX_FMT_SGRBG10DPCM8 ('BD10'), V4L2_PIX_FMT_SRGGB10DPCM8 ('bRA8'),
- pixfmt-srggb10-ipu3
- V4L2_PIX_FMT_SRGGB12 ('RG12'), V4L2_PIX_FMT_SGRBG12 ('BA12'), V4L2_PIX_FMT_SGBRG12 ('GB12'), V4L2_PIX_FMT_SBGGR12 ('BG12'),
- V4L2_PIX_FMT_SRGGB12P ('pRCC'), V4L2_PIX_FMT_SGRBG12P ('pgCC'), V4L2_PIX_FMT_SGBRG12P ('pGCC'), V4L2_PIX_FMT_SBGGR12P ('pBCC')
- V4L2_PIX_FMT_SRGGB14 ('RG14'), V4L2_PIX_FMT_SGRBG14 ('GR14'), V4L2_PIX_FMT_SGBRG14 ('GB14'), V4L2_PIX_FMT_SBGGR14 ('BG14'),
- pixfmt-srggb14p
- V4L2_PIX_FMT_SRGGB16 ('RG16'), V4L2_PIX_FMT_SGRBG16 ('GR16'), V4L2_PIX_FMT_SGBRG16 ('GB16'), V4L2_PIX_FMT_SBGGR16 ('BYR2'),
V4L2_PIX_FMT_CNF4 ('CNF4')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Depth sensor confidence information as a 4 bits per pixel packed array
Description #
Proprietary format used by Intel RealSense Depth cameras containing depth confidence information in range 0-15 with 0 indicating that the sensor was unable to resolve any signal and 15 indicating maximum level of confidence for the specific sensor (actual error margins might change from sensor to sensor).
Every two consecutive pixels are packed into a single byte. Bits 0-3 of byte n refer to confidence value of depth pixel 2*n, bits 4-7 to confidence value of depth pixel 2*n+1.
Bit-packed representation.
|
Y'01[3:0](bits 7--4) Y'00[3:0](bits 3--0) |
Y'03[3:0](bits 7--4) Y'02[3:0](bits 3--0) |
Compressed Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
|
Identifier |
Code |
Details |
|---|---|---|
|
|
'JPEG' |
TBD. See also VIDIOC_G_JPEGCOMP, VIDIOC_S_JPEGCOMP. |
|
|
'MPEG' |
MPEG multiplexed stream. The actual format is determined by extended control |
|
|
'H264' |
H264 Access Unit. The decoder expects one Access Unit per buffer. The encoder generates one Access Unit per buffer. If vidioc_enum_fmt reports |
|
|
'AVC1' |
H264 video elementary stream without start codes. |
|
|
'M264' |
H264 MVC video elementary stream. |
|
|
'S264' |
H264 parsed slice data, including slice headers, either with or without the start code, as extracted from the H264 bitstream. This format is adapted for stateless video decoders that implement an H264 pipeline with the stateless_decoder. This pixelformat has two modifiers that must be set at least once through the The syntax for this format is documented in h264, section 7.3.2.8 "Slice layer without partitioning RBSP syntax" and the following sections. |
|
|
'H263' |
H263 video elementary stream. |
|
|
'SPK0' |
Sorenson Spark is an implementation of H.263 for use in Flash Video and Adobe Flash files |
|
|
'MPG1' |
MPEG1 Picture. Each buffer starts with a Picture header, followed by other headers as needed and ending with the Picture data. If vidioc_enum_fmt reports |
|
|
'MPG2' |
MPEG2 Picture. Each buffer starts with a Picture header, followed by other headers as needed and ending with the Picture data. If vidioc_enum_fmt reports |
|
|
'MG2S' |
MPEG-2 parsed slice data, as extracted from the MPEG-2 bitstream. This format is adapted for stateless video decoders that implement a MPEG-2 pipeline with the stateless_decoder. Metadata associated with the frame to decode is required to be passed through the |
|
|
'MPG4' |
MPEG4 video elementary stream. |
|
|
'XVID' |
Xvid video elementary stream. |
|
|
'VC1G' |
VC1, SMPTE 421M Annex G compliant stream. |
|
|
'VC1L' |
VC1, SMPTE 421M Annex L compliant stream. |
|
|
'VP80' |
VP8 compressed video frame. The encoder generates one compressed frame per buffer, and the decoder requires one compressed frame per buffer. |
|
|
'VP8F' |
VP8 parsed frame, including the frame header, as extracted from the container. This format is adapted for stateless video decoders that implement an VP8 pipeline with the stateless_decoder. Metadata associated with the frame to decode is required to be passed through the |
|
|
'VP90' |
VP9 compressed video frame. The encoder generates one compressed frame per buffer, and the decoder requires one compressed frame per buffer. |
|
|
'VP9F' |
VP9 parsed frame, including the frame header, as extracted from the container. This format is adapted for stateless video decoders that implement a VP9 pipeline with the stateless_decoder. Metadata associated with the frame to decode is required to be passed through the |
|
|
'HEVC' |
HEVC/H.265 Access Unit. The decoder expects one Access Unit per buffer. The encoder generates one Access Unit per buffer. If vidioc_enum_fmt reports |
|
|
'S265' |
HEVC parsed slice data, as extracted from the HEVC bitstream. This format is adapted for stateless video decoders that implement a HEVC pipeline (using the mem2mem and media-request-api). This pixelformat has two modifiers that must be set at least once through the |
|
|
'FWHT' |
Video elementary stream using a codec based on the Fast Walsh Hadamard Transform. This codec is implemented by the vicodec ('Virtual Codec') driver. See the codec-fwht.h header for more details. vidioc_enum_fmt reports |
|
|
'SFWH' |
Same format as V4L2_PIX_FMT_FWHT but requires stateless codec implementation. Metadata associated with the frame to decode is required to be passed through the |
|
|
'RV30' |
RealVideo, or also spelled as Real Video, is a suite of proprietary video compression formats developed by RealNetworks - the specific format changes with the version. RealVideo codecs are identified by four-character codes. RV30 corresponds to RealVideo 8, suspected to be based largely on an early draft of H.264 |
|
|
'RV40' |
RV40 represents RealVideo 9 and RealVideo 10. RealVideo 9, suspected to be based on H.264. RealVideo 10, aka RV9 EHQ, This refers to an improved encoder for the RV9 format that is fully backwards compatible with RV9 players - the format and decoder did not change, only the encoder did. As a result, it uses the same FourCC. |
|
|
'AV1F' |
AV1 parsed frame, including the frame header, as extracted from the container. This format is adapted for stateless video decoders that implement a AV1 pipeline with the stateless_decoder. Metadata associated with the frame to decode is required to be passed through the |
|
|
'AV01' |
AV1 compressed video frame. This format is adapted for implementing AV1 pipeline. The decoder implements stateful video decoder and expects one temporal unit per buffer in OBU stream format. The encoder generates one Temporal Unit per buffer. |
Indexed Format
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
In this format each pixel is represented by an 8 bit index into a 256 entry ARGB palette. It is intended for Video Output Overlays only. There are no ioctls to access the palette, this must be done with ioctls of the Linux framebuffer API.
|
Identifier |
Code |
Byte 0 |
||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
|
'PAL8' |
i7 |
i6 |
i5 |
i4 |
i3 |
i2 |
i1 |
i0 |
|
Standard Image Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
In order to exchange images between drivers and applications, it is necessary to have standard image data formats which both sides will interpret the same way. V4L2 includes several such formats, and this section is intended to be an unambiguous specification of the standard image data formats in V4L2.
V4L2 drivers are not limited to these formats, however. Driver-specific formats are possible. In that case the application may depend on a codec to convert images to one of the standard formats when needed. But the data can still be stored and retrieved in the proprietary format. For example, a device may support a proprietary compressed format. Applications can still capture and save the data in the compressed format, saving much disk space, and later use a codec to convert the images to the X Windows screen format when the video is to be displayed.
Even so, ultimately, some standard formats are needed, so the V4L2 specification would not be complete without well-defined standard formats.
The V4L2 standard formats are mainly uncompressed formats. The pixels are always arranged in memory from left to right, and from top to bottom. The first byte of data in the image buffer is always for the leftmost pixel of the topmost row. Following that is the pixel immediately to its right, and so on until the end of the top row of pixels. Following the rightmost pixel of the row there may be zero or more bytes of padding to guarantee that each row of pixel data has a certain alignment. Following the pad bytes, if any, is data for the leftmost pixel of the second row from the top, and so on. The last row has just as many pad bytes after it as the other rows.
In V4L2 each format has an identifier which looks like PIX_FMT_XXX, defined in the videodev2.h header file. These identifiers represent four character (FourCC) codes which are also listed below, however they are not the same as those used in the Windows world.
For some formats, data is stored in separate, discontiguous memory buffers. Those formats are identified by a separate set of FourCC codes and are referred to as "multi-planar formats". For example, a YUV422 frame is normally stored in one memory buffer, but it can also be placed in two or three separate buffers, with Y component in one buffer and CbCr components in another in the 2-planar version or with each component in its own buffer in the 3-planar case. Those sub-buffers are referred to as "planes".
V4L2_PIX_FMT_INZI ('INZI')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Infrared 10-bit linked with Depth 16-bit images
Description #
Proprietary multi-planar format used by Intel SR300 Depth cameras, comprise of Infrared image followed by Depth data. The pixel definition is 32-bpp, with the Depth and Infrared Data split into separate continuous planes of identical dimensions.
The first plane - Infrared data - is stored according to V4L2_PIX_FMT_Y10 greyscale format. Each pixel is 16-bit cell, with actual data stored in the 10 LSBs with values in range 0 to 1023. The six remaining MSBs are padded with zeros.
The second plane provides 16-bit per-pixel Depth data arranged in V4L2-PIX-FMT-Z16 format.
Frame Structure. Each cell is a 16-bit word with more significant data stored at higher memory address (byte order is little-endian).
|
Ir0,0 |
Ir0,1 |
Ir0,2 |
... |
... |
... |
|---|---|---|---|---|---|
|
... |
|||||
|
Infrared Data |
|||||
|
... |
|||||
|
... |
... |
... |
Irn-1,n-3 |
Irn-1,n-2 |
Irn-1,n-1 |
|
Depth0,0 |
Depth0,1 |
Depth0,2 |
... |
... |
... |
|
... |
|||||
|
Depth Data |
|||||
|
... |
|||||
|
... |
... |
... |
Depthn-1,n-3 |
Depthn-1,n-2 |
Depthn-1,n-1 |
V4L2_PIX_FMT_M420 ('M420')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Format with ½ horizontal and vertical chroma resolution, also known as YUV 4:2:0. Hybrid plane line-interleaved layout.
Description #
M420 is a YUV format with ½ horizontal and vertical chroma subsampling (YUV 4:2:0). Pixels are organized as interleaved luma and chroma planes. Two lines of luma data are followed by one line of chroma data.
The luma plane has one byte per pixel. The chroma plane contains interleaved CbCr pixels subsampled by ½ in the horizontal and vertical directions. Each CbCr pair belongs to four pixels. For example, Cb0/Cr0 belongs to Y'00, Y'01, Y'10, Y'11.
All line lengths are identical: if the Y lines include pad bytes so do the CbCr lines.
Byte Order. Each cell is one byte.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start + 16: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 20: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 24: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
Color Sample Location: Chroma samples are interstitially sited horizontally and vertically.
Packed HSV formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Description #
The hue (h) is measured in degrees, the equivalence between degrees and LSBs depends on the hsv-encoding used, see colorspaces. The saturation (s) and the value (v) are measured in percentage of the cylinder: 0 being the smallest value and 255 the maximum.
The values are packed in 24 or 32 bit formats.
|
Identifier |
Code |
Byte 0 in memory |
Byte 1 |
Byte 2 |
Byte 3 |
|||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
|
'HSV4' |
h7 |
h6 |
h5 |
h4 |
h3 |
h2 |
h1 |
h0 |
s7 |
s6 |
s5 |
s4 |
s3 |
s2 |
s1 |
s0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||
|
|
'HSV3' |
h7 |
h6 |
h5 |
h4 |
h3 |
h2 |
h1 |
h0 |
s7 |
s6 |
s5 |
s4 |
s3 |
s2 |
s1 |
s0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||
Bit 7 is the most significant bit.
Packed YUV formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Similarly to the packed RGB formats, the packed YUV formats store the Y, Cb and Cr components consecutively in memory. They may apply subsampling to the chroma components and thus differ in how they interlave the three components.
4:4:4 Subsampling #
These formats do not subsample the chroma components and store each pixels as a full triplet of Y, Cb and Cr values.
The next table lists the packed YUV 4:4:4 formats with less than 8 bits per component. They are named based on the order of the Y, Cb and Cr components as seen in a 16-bit word, which is then stored in memory in little endian byte order, and on the number of bits for each component. For instance the YUV565 format stores a pixel in a 16-bit word [15:0] laid out at as [Y'4-0 Cb5-0 Cr4-0], and stored in memory in two bytes, [Cb2-0 Cr4-0] followed by [Y'4-0 Cb5-3].
|
Identifier |
Code |
Byte 0 in memory |
Byte 1 |
||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
|
'Y444' |
Cb3 |
Cb2 |
Cb1 |
Cb0 |
Cr3 |
Cr2 |
Cr1 |
Cr0 |
a3 |
a2 |
a1 |
a0 |
Y'3 |
Y'2 |
Y'1 |
Y'0 |
|
|
'YUVO' |
Cb2 |
Cb1 |
Cb0 |
Cr4 |
Cr3 |
Cr2 |
Cr1 |
Cr0 |
a |
Y'4 |
Y'3 |
Y'2 |
Y'1 |
Y'0 |
Cb4 |
Cb3 |
|
|
'YUVP' |
Cb2 |
Cb1 |
Cb0 |
Cr4 |
Cr3 |
Cr2 |
Cr1 |
Cr0 |
Y'4 |
Y'3 |
Y'2 |
Y'1 |
Y'0 |
Cb5 |
Cb4 |
Cb3 |
The next table lists the packed YUV 4:4:4 formats with 8 bits per component. They are named based on the order of the Y, Cb and Cr components as stored in memory, and on the total number of bits per pixel. For instance, the VUYX32 format stores a pixel with Cr7-0 in the first byte, Cb7-0 in the second byte and Y'7-0 in the third byte.
|
Identifier |
Code |
Byte 0 |
Byte 1 |
Byte 2 |
Byte 3 |
|---|---|---|---|---|---|
|
|
'YUV4' |
A7-0 |
Y'7-0 |
Cb7-0 |
Cr7-0 |
|
|
'AYUV' |
A7-0 |
Y'7-0 |
Cb7-0 |
Cr7-0 |
|
|
'XYUV' |
X7-0 |
Y'7-0 |
Cb7-0 |
Cr7-0 |
|
|
'VUYA' |
Cr7-0 |
Cb7-0 |
Y'7-0 |
A7-0 |
|
|
'VUYX' |
Cr7-0 |
Cb7-0 |
Y'7-0 |
X7-0 |
|
|
'YUVA' |
Y'7-0 |
Cb7-0 |
Cr7-0 |
A7-0 |
|
|
'YUVX' |
Y'7-0 |
Cb7-0 |
Cr7-0 |
X7-0 |
|
|
'YUV3' |
Y'7-0 |
Cb7-0 |
Cr7-0 |
- |
The next table lists the packed YUV 4:4:4 formats with 12 bits per component. Expand the bits per component to 16 bits, data in the high bits, zeros in the low bits, arranged in little endian order, storing 1 pixel in 6 bytes.
|
Identifier |
Code |
Byte 1-0 |
Byte 3-2 |
Byte 5-4 |
Byte 7-6 |
Byte 9-8 |
Byte 11-10 |
|---|---|---|---|---|---|---|---|
|
|
'Y312' |
Y'0 |
Cb0 |
Cr0 |
Y'1 |
Cb1 |
Cr1 |
4:2:2 Subsampling #
These formats, commonly referred to as YUYV or YUY2, subsample the chroma components horizontally by 2, storing 2 pixels in a container. The container is 32-bits for 8-bit formats, and 64-bits for 10+-bit formats.
The packed YUYV formats with more than 8 bits per component are stored as four 16-bit little-endian words. Each word's most significant bits contain one component, and the least significant bits are zero padding.
|
Identifier |
Code |
Byte 0 |
Byte 1 |
Byte 2 |
Byte 3 |
Byte 4 |
Byte 5 |
Byte 6 |
Byte 7 |
|---|---|---|---|---|---|---|---|---|---|
|
|
'UYVY' |
Cb0 |
Y'0 |
Cr0 |
Y'1 |
Cb2 |
Y'2 |
Cr2 |
Y'3 |
|
|
'VYUY' |
Cr0 |
Y'0 |
Cb0 |
Y'1 |
Cr2 |
Y'2 |
Cb2 |
Y'3 |
|
|
'YUYV' |
Y'0 |
Cb0 |
Y'1 |
Cr0 |
Y'2 |
Cb2 |
Y'3 |
Cr2 |
|
|
'YVYU' |
Y'0 |
Cr0 |
Y'1 |
Cb0 |
Y'2 |
Cr2 |
Y'3 |
Cb2 |
|
Identifier |
Code |
Word 0 |
Word 1 |
Word 2 |
Word 3 |
|---|---|---|---|---|---|
|
|
'Y210' |
Y'0 (bits 15-6) |
Cb0 (bits 15-6) |
Y'1 (bits 15-6) |
Cr0 (bits 15-6) |
|
|
'Y212' |
Y'0 (bits 15-4) |
Cb0 (bits 15-4) |
Y'1 (bits 15-4) |
Cr0 (bits 15-4) |
|
|
'Y216' |
Y'0 (bits 15-0) |
Cb0 (bits 15-0) |
Y'1 (bits 15-0) |
Cr0 (bits 15-0) |
Color Sample Location: Chroma samples are interstitially sited horizontally.
4:1:1 Subsampling #
This format subsamples the chroma components horizontally by 4, storing 8 pixels in 12 bytes.
|
Identifier |
Code |
Byte 0 |
Byte 1 |
Byte 2 |
Byte 3 |
Byte 4 |
Byte 5 |
Byte 6 |
Byte 7 |
Byte 8 |
Byte 9 |
Byte 10 |
Byte 11 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
'Y41P' |
Cb0 |
Y'0 |
Cr0 |
Y'1 |
Cb4 |
Y'2 |
Cr4 |
Y'3 |
Y'4 |
Y'5 |
Y'6 |
Y'7 |
Color Sample Location: Chroma samples are interstitially sited horizontally.
V4L2_PIX_FMT_RAW_CRU10 ('CR10'), V4L2_PIX_FMT_RAW_CRU12 ('CR12'), V4L2_PIX_FMT_RAW_CRU14 ('CR14'), V4L2_PIX_FMT_RAW_CRU20 ('CR20')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Renesas RZ/V2H Camera Receiver Unit 64-bit packed pixel formats #
V4L2_PIX_FMT_RAW_CRU10 (CR10)
V4L2_PIX_FMT_RAW_CRU12 (CR12)
V4L2_PIX_FMT_RAW_CRU14 (CR14)
V4L2_PIX_FMT_RAW_CRU20 (CR20)
Description #
These pixel formats are some of the RAW outputs for the Camera Receiver Unit in the Renesas RZ/V2H SoC. They are raw formats which pack pixels contiguously into 64-bit units, with the 4 or 8 most significant bits padded.
Byte Order
|
Pixel Format Code |
Data organization |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
63 |
62 |
61 |
60 |
59 |
58 |
57 |
56 |
55 |
54 |
53 |
52 |
51 |
50 |
49 |
48 |
47 |
46 |
45 |
44 |
43 |
42 |
41 |
40 |
39 |
38 |
37 |
36 |
35 |
34 |
33 |
32 |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|
|
V4L2_PIX_FMT_RAW_CRU10 |
0 |
0 |
0 |
0 |
P5 |
P4 |
P3 |
P2 |
P1 |
P0 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
V4L2_PIX_FMT_RAW_CRU12 |
0 |
0 |
0 |
0 |
P4 |
P3 |
P2 |
P1 |
P0 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
V4L2_PIX_FMT_RAW_CRU14 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
P3 |
P2 |
P1 |
P0 |
||||||||||||||||||||||||||||||||||||||||||||||||||||
|
V4L2_PIX_FMT_RAW_CRU20 |
0 |
0 |
0 |
0 |
P2 |
P1 |
P0 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Reserved Format Identifiers
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
These formats are not defined by this specification, they are just listed for reference and to avoid naming conflicts. If you want to register your own format, send an e-mail to the linux-media mailing list https://linuxtv.org/lists.php for inclusion in the videodev2.h file. If you want to share your format with other developers add a link to your documentation and send a copy to the linux-media mailing list for inclusion in this section. If you think your format should be listed in a standard format section please make a proposal on the linux-media mailing list.
|
Identifier |
Code |
Details |
|---|---|---|
|
|
'dvsd' |
unknown |
|
|
'E625' |
Compressed format of the ET61X251 driver. |
|
|
'HI24' |
8 bit RGB format used by the BTTV driver. |
|
|
'CPIA' |
YUV format used by the gspca cpia1 driver. |
|
|
'JPGL' |
JPEG-Light format (Pegasus Lossless JPEG) used in Divio webcams NW 80x. |
|
|
'S501' |
YUYV per line used by the gspca driver. |
|
|
'S505' |
YYUV per line used by the gspca driver. |
|
|
'S508' |
YUVY per line used by the gspca driver. |
|
|
'S561' |
Compressed GBRG Bayer format used by the gspca driver. |
|
|
'P207' |
Compressed BGGR Bayer format used by the gspca driver. |
|
|
'M310' |
Compressed BGGR Bayer format used by the gspca driver. |
|
|
'JL20' |
JPEG compressed RGGB Bayer format used by the gspca driver. |
|
|
'O511' |
OV511 JPEG format used by the gspca driver. |
|
|
'O518' |
OV518 JPEG format used by the gspca driver. |
|
|
'PJPG' |
Pixart 73xx JPEG format used by the gspca driver. |
|
|
'S401' |
Compressed RGB format used by the gspca se401 driver |
|
|
'905C' |
Compressed RGGB bayer format used by the gspca driver. |
|
|
'MJPG' |
Compressed format used by the Zoran driver |
|
|
'PWC1' |
Compressed format of the PWC driver. |
|
|
'PWC2' |
Compressed format of the PWC driver. |
|
|
'S910' |
Compressed format of the SN9C102 driver. |
|
|
'S920' |
YUV 4:2:0 format of the gspca sn9c20x driver. |
|
|
'SONX' |
Compressed GBRG bayer format of the gspca sn9c2028 driver. |
|
|
'S680' |
Bayer format of the gspca stv0680 driver. |
|
|
'WNVA' |
Used by the Winnov Videum driver, http://www.thedirks.org/winnov/ |
|
|
'TM60' |
Used by Trident tm6000 |
|
|
'CITV' |
Used by xirlink CIT, found at IBM webcams. Uses one line of Y then 1 line of VYUY |
|
|
'KONI' |
Used by Konica webcams. YUV420 planar in blocks of 256 pixels. |
|
|
'YYUV' |
unknown |
|
|
'Y04 ' |
Old 4-bit greyscale format. Only the most significant 4 bits of each byte are used, the other bits are set to 0. |
|
|
'Y06 ' |
Old 6-bit greyscale format. Only the most significant 6 bits of each byte are used, the other bits are set to 0. |
|
|
'S5CI' |
Two-planar format used by Samsung S5C73MX cameras. The first plane contains interleaved JPEG and UYVY image data, followed by meta data in form of an array of offsets to the UYVY data blocks. The actual pointer array follows immediately the interleaved JPEG/UYVY data, the number of entries in this array equals the height of the UYVY image. Each entry is a 4-byte unsigned integer in big endian order and it's an offset to a single pixel line of the UYVY image. The first plane can start either with JPEG or UYVY data chunk. The size of a single UYVY block equals the UYVY image's width multiplied by 2. The size of a JPEG chunk depends on the image and can vary with each line. The second plane, at an offset of 4084 bytes, contains a 4-byte offset to the pointer array in the first plane. This offset is followed by a 4-byte value indicating size of the pointer array. All numbers in the second plane are also in big endian order. Remaining data in the second plane is undefined. The information in the second plane allows to easily find location of the pointer array, which can be different for each frame. The size of the pointer array is constant for given UYVY image height. In order to extract UYVY and JPEG frames an application can initially set a data pointer to the start of first plane and then add an offset from the first entry of the pointers table. Such a pointer indicates start of an UYVY image pixel line. Whole UYVY line can be copied to a separate buffer. These steps should be repeated for each line, i.e. the number of entries in the pointer array. Anything what's in between the UYVY lines is JPEG data and should be concatenated to form the JPEG stream. |
|
|
'MT21' |
Compressed two-planar YVU420 format used by Mediatek MT8173, MT8192, MT8195 and more. The compression is lossless. This format have similitude with |
|
|
'QC08C' |
Compressed Macro-tile 8-Bit YUV420 format used by Qualcomm platforms. It is an opaque intermediate format. The used compression is lossless and it is used by various multimedia hardware blocks like GPU, display controllers, ISP and video accelerators. It contains four planes for progressive video and eight planes for interlaced video. |
|
|
'QC10C' |
Compressed Macro-tile 10-Bit YUV420 format used by Qualcomm platforms. It is an opaque intermediate format. The used compression is lossless and it is used by various multimedia hardware blocks like GPU, display controllers, ISP and video accelerators. It contains four planes for progressive video. |
|
|
'AJPG' |
ASPEED JPEG format used by the aspeed-video driver on Aspeed platforms, which is generally adapted for remote KVM. On each frame compression, I will compare the new frame with previous one to decide which macroblock's data is changed, and only the changed macroblocks will be compressed. The implementation is based on AST2600 A3 datasheet, revision 0.9, which is not publicly available. Or you can reference Video stream data format – ASPEED mode compression of SDK_User_Guide which available on github. Decoder's implementation can be found here, aspeed_codec |
|
|
'HXTL' |
Compressed format used by Nuvoton NPCM video driver. This format is defined in Remote Framebuffer Protocol (RFC 6143, chapter 7.7.4 Hextile Encoding). |
RGB Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
These formats encode each pixel as a triplet of RGB values. They are packed formats, meaning that the RGB values for one pixel are stored consecutively in memory and each pixel consumes an integer number of bytes. When the number of bits required to store a pixel is not aligned to a byte boundary, the data is padded with additional bits to fill the remaining byte.
The formats differ by the number of bits per RGB component (typically but not always the same for all components), the order of components in memory, and the presence of an alpha component or additional padding bits.
The usage and value of the alpha bits in formats that support them (named ARGB or a permutation thereof, collectively referred to as alpha formats) depend on the device type and hardware operation. Capture devices (including capture queues of mem-to-mem devices) fill the alpha component in memory. When the device captures an alpha channel the alpha component will have a meaningful value. Otherwise, when the device doesn't capture an alpha channel but can set the alpha bit to a user-configurable value, the V4L2_CID_ALPHA_COMPONENT control is used to specify that alpha value, and the alpha component of all pixels will be set to the value specified by that control. Otherwise a corresponding format without an alpha component (XRGB or XBGR) must be used instead of an alpha format.
Output devices (including output queues of mem-to-mem devices and video output overlay devices) read the alpha component from memory. When the device processes the alpha channel the alpha component must be filled with meaningful values by applications. Otherwise a corresponding format without an alpha component (XRGB or XBGR) must be used instead of an alpha format.
Formats that contain padding bits are named XRGB (or a permutation thereof). The padding bits contain undefined values and must be ignored by applications, devices and drivers, for both capture and output devices.
Less Than 8 Bits Per Component #
These formats store an RGB triplet in one, two or four bytes. They are named based on the order of the RGB components as seen in a 8-, 16- or 32-bit word, which is then stored in memory in little endian byte order (unless otherwise noted by the presence of bit 31 in the 4CC value), and on the number of bits for each component. For instance, the RGB565 format stores a pixel in a 16-bit word [15:0] laid out at as [R4 R3 R2 R1 R0 G5 G4 G3 G2 G1 G0 B4 B3 B2 B1 B0], and stored in memory in two bytes, [R4 R3 R2 R1 R0 G5 G4 G3] followed by [G2 G1 G0 B4 B3 B2 B1 B0].
|
Identifier |
Code |
Byte 0 in memory |
Byte 1 |
Byte 2 |
Byte 3 |
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
|
'RGB1' |
r2 |
r1 |
r0 |
g2 |
g1 |
g0 |
b1 |
b0 |
||||||||||||||||||||||||
|
|
'AR12' |
g3 |
g2 |
g1 |
g0 |
b3 |
b2 |
b1 |
b0 |
a3 |
a2 |
a1 |
a0 |
r3 |
r2 |
r1 |
r0 |
||||||||||||||||
|
|
'XR12' |
g3 |
g2 |
g1 |
g0 |
b3 |
b2 |
b1 |
b0 |
x |
x |
x |
x |
r3 |
r2 |
r1 |
r0 |
||||||||||||||||
|
|
'RA12' |
b3 |
b2 |
b1 |
b0 |
a3 |
a2 |
a1 |
a0 |
r3 |
r2 |
r1 |
r0 |
g3 |
g2 |
g1 |
g0 |
||||||||||||||||
|
|
'RX12' |
b3 |
b2 |
b1 |
b0 |
x |
x |
x |
x |
r3 |
r2 |
r1 |
r0 |
g3 |
g2 |
g1 |
g0 |
||||||||||||||||
|
|
'AB12' |
g3 |
g2 |
g1 |
g0 |
r3 |
r2 |
r1 |
r0 |
a3 |
a2 |
a1 |
a0 |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||
|
|
'XB12' |
g3 |
g2 |
g1 |
g0 |
r3 |
r2 |
r1 |
r0 |
x |
x |
x |
x |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||
|
|
'BA12' |
r3 |
r2 |
r1 |
r0 |
a3 |
a2 |
a1 |
a0 |
b3 |
b2 |
b1 |
b0 |
g3 |
g2 |
g1 |
g0 |
||||||||||||||||
|
|
'BX12' |
r3 |
r2 |
r1 |
r0 |
x |
x |
x |
x |
b3 |
b2 |
b1 |
b0 |
g3 |
g2 |
g1 |
g0 |
||||||||||||||||
|
|
'AR15' |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
a |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
||||||||||||||||
|
|
'XR15' |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
x |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
||||||||||||||||
|
|
'RA15' |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
a |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
g2 |
||||||||||||||||
|
|
'RX15' |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
x |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
g2 |
||||||||||||||||
|
|
'AB15' |
g2 |
g1 |
g0 |
r4 |
r3 |
r2 |
r1 |
r0 |
a |
b4 |
b3 |
b2 |
b1 |
b0 |
g4 |
g3 |
||||||||||||||||
|
|
'XB15' |
g2 |
g1 |
g0 |
r4 |
r3 |
r2 |
r1 |
r0 |
x |
b4 |
b3 |
b2 |
b1 |
b0 |
g4 |
g3 |
||||||||||||||||
|
|
'BA15' |
g1 |
g0 |
r4 |
r3 |
r2 |
r1 |
r0 |
a |
b4 |
b3 |
b2 |
b1 |
b0 |
g4 |
g3 |
g2 |
||||||||||||||||
|
|
'BX15' |
g1 |
g0 |
r4 |
r3 |
r2 |
r1 |
r0 |
x |
b4 |
b3 |
b2 |
b1 |
b0 |
g4 |
g3 |
g2 |
||||||||||||||||
|
|
'RGBP' |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
||||||||||||||||
|
|
'AR15' | (1 << 31) |
a |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||
|
|
'XR15' | (1 << 31) |
x |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||
|
|
'RGBR' |
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||
|
|
'BGRH' |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
8 Bits Per Component #
These formats store an RGB triplet in three or four bytes. They are named based on the order of the RGB components as stored in memory, and on the total number of bits per pixel. For instance, RGB24 format stores a pixel with [R7 R6 R5 R4 R3 R2 R1 R0] in the first byte, [G7 G6 G5 G4 G3 G2 G1 G0] in the second byte and [B7 B6 B5 B4 B3 B2 B1 B0] in the third byte. This differs from the DRM format nomenclature that instead use the order of components as seen in a 24- or 32-bit little endian word.
|
Identifier |
Code |
Byte 0 in memory |
Byte 1 |
Byte 2 |
Byte 3 |
|---|---|---|---|---|---|
|
|
'BGR3' |
B7-0 |
G7-0 |
R7-0 |
|
|
|
'RGB3' |
R7-0 |
G7-0 |
B7-0 |
|
|
|
'AR24' |
B7-0 |
G7-0 |
R7-0 |
A7-0 |
|
|
'XR24' |
B7-0 |
G7-0 |
R7-0 |
X7-0 |
|
|
'RA24' |
A7-0 |
B7-0 |
G7-0 |
R7-0 |
|
|
'RX24' |
X7-0 |
B7-0 |
G7-0 |
R7-0 |
|
|
'AB24' |
R7-0 |
G7-0 |
B7-0 |
A7-0 |
|
|
'XB24' |
R7-0 |
G7-0 |
B7-0 |
X7-0 |
|
|
'BA24' |
A7-0 |
R7-0 |
G7-0 |
B7-0 |
|
|
'BX24' |
X7-0 |
R7-0 |
G7-0 |
B7-0 |
10 Bits Per Component #
These formats store a 30-bit RGB triplet with an optional 2 bit alpha in four bytes. They are named based on the order of the RGB components as seen in a 32-bit word, which is then stored in memory in little endian byte order (unless otherwise noted by the presence of bit 31 in the 4CC value), and on the number of bits for each component.
|
Identifier |
Code |
Byte 0 in memory |
Byte 1 |
Byte 2 |
Byte 3 |
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
|
'RX30' |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
x |
x |
g3 |
g2 |
g1 |
g0 |
b9 |
b8 |
b7 |
b6 |
r1 |
r0 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
|
|
'RA30' |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
a1 |
a0 |
g3 |
g2 |
g1 |
g0 |
b9 |
b8 |
b7 |
b6 |
r1 |
r0 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
|
|
'AR30' |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b9 |
b8 |
r3 |
r2 |
r1 |
r0 |
g9 |
g8 |
g7 |
g6 |
a1 |
a0 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
12 Bits Per Component #
These formats store an RGB triplet in six or eight bytes, with 12 bits per component. Expand the bits per component to 16 bits, data in the high bits, zeros in the low bits, arranged in little endian order.
|
Identifier |
Code |
Byte 1-0 |
Byte 3-2 |
Byte 5-4 |
Byte 7-6 |
|---|---|---|---|---|---|
|
|
'B312' |
B15-4 |
G15-4 |
R15-4 |
|
|
|
'B412' |
B15-4 |
G15-4 |
R15-4 |
A15-4 |
16 Bits Per Component #
These formats store an RGB triplet in six bytes, with 16 bits per component stored in memory in little endian byte order. They are named based on the order of the RGB components as stored in memory. For instance, RGB48 stores R7:0 and R15:8 in bytes 0 and 1 respectively. This differs from the DRM format nomenclature that instead uses the order of components as seen in the 48-bits little endian word.
|
Identifier |
Code |
Byte 0 |
Byte 1 |
Byte 2 |
Byte 3 |
Byte 4 |
Byte 5 |
|---|---|---|---|---|---|---|---|
|
|
'BGR6' |
B7-0 |
B15-8 |
G7-0 |
G15-8 |
R7-0 |
R15-8 |
|
|
'RGB6' |
R7-0 |
R15-8 |
G7-0 |
G15-8 |
B7-0 |
B15-8 |
Deprecated RGB Formats #
Formats defined in pixfmt-rgb-deprecated are deprecated and must not be used by new drivers. They are documented here for reference. The meaning of their alpha bits (a) is ill-defined and they are interpreted as in either the corresponding ARGB or XRGB format, depending on the driver.
|
Identifier |
Code |
Byte 0 in memory |
Byte 1 |
Byte 2 |
Byte 3 |
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
|
'R444' |
g3 |
g2 |
g1 |
g0 |
b3 |
b2 |
b1 |
b0 |
a3 |
a2 |
a1 |
a0 |
r3 |
r2 |
r1 |
r0 |
||||||||||||||||
|
|
'RGBO' |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
a |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
||||||||||||||||
|
|
'RGBQ' |
a |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||
|
|
'BGR4' |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
a7 |
a6 |
a5 |
a4 |
a3 |
a2 |
a1 |
a0 |
|
|
'RGB4' |
a7 |
a6 |
a5 |
a4 |
a3 |
a2 |
a1 |
a0 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
A test utility to determine which RGB formats a driver actually supports is available from the LinuxTV v4l-dvb repository. See https://linuxtv.org/repo/ for access instructions.
V4L2_SDR_FMT_CS8 ('CS08')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Complex signed 8-bit IQ sample
Description #
This format contains sequence of complex number samples. Each complex number consist two parts, called In-phase and Quadrature (IQ). Both I and Q are represented as a 8 bit signed number. I value comes first and Q value after that.
Byte Order. Each cell is one byte.
|
start + 0: |
I'0 |
|
start + 1: |
Q'0 |
V4L2_SDR_FMT_CS14LE ('CS14')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Complex signed 14-bit little endian IQ sample
Description #
This format contains sequence of complex number samples. Each complex number consist two parts, called In-phase and Quadrature (IQ). Both I and Q are represented as a 14 bit signed little endian number. I value comes first and Q value after that. 14 bit value is stored in 16 bit space with unused high bits padded with 0.
Byte Order. Each cell is one byte.
|
start + 0: |
I'0[7:0] |
I'0[13:8] |
|
start + 2: |
Q'0[7:0] |
Q'0[13:8] |
V4L2_SDR_FMT_CU8 ('CU08')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Complex unsigned 8-bit IQ sample
Description #
This format contains sequence of complex number samples. Each complex number consist two parts, called In-phase and Quadrature (IQ). Both I and Q are represented as a 8 bit unsigned number. I value comes first and Q value after that.
Byte Order. Each cell is one byte.
|
start + 0: |
I'0 |
|
start + 1: |
Q'0 |
V4L2_SDR_FMT_CU16LE ('CU16')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Complex unsigned 16-bit little endian IQ sample
Description #
This format contains sequence of complex number samples. Each complex number consist two parts, called In-phase and Quadrature (IQ). Both I and Q are represented as a 16 bit unsigned little endian number. I value comes first and Q value after that.
Byte Order. Each cell is one byte.
|
start + 0: |
I'0[7:0] |
I'0[15:8] |
|
start + 2: |
Q'0[7:0] |
Q'0[15:8] |
V4L2_SDR_FMT_PCU16BE ('PC16')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Planar complex unsigned 16-bit big endian IQ sample
Description #
This format contains a sequence of complex number samples. Each complex number consist of two parts called In-phase and Quadrature (IQ). Both I and Q are represented as a 16 bit unsigned big endian number stored in 32 bit space. The remaining unused bits within the 32 bit space will be padded with 0. I value starts first and Q value starts at an offset equalling half of the buffer size (i.e.) offset = buffersize/2. Out of the 16 bits, bit 15:2 (14 bit) is data and bit 1:0 (2 bit) can be any value.
Byte Order. Each cell is one byte.
|
Offset: |
Byte B0 |
Byte B1 |
Byte B2 |
Byte B3 |
|---|---|---|---|---|
|
start + 0: |
I'0[13:6] |
I'0[5:0]; B1[1:0]=pad |
pad |
pad |
|
start + 4: |
I'1[13:6] |
I'1[5:0]; B1[1:0]=pad |
pad |
pad |
|
... |
||||
|
start + offset: |
Q'0[13:6] |
Q'0[5:0]; B1[1:0]=pad |
pad |
pad |
|
start + offset + 4: |
Q'1[13:6] |
Q'1[5:0]; B1[1:0]=pad |
pad |
pad |
V4L2_SDR_FMT_PCU18BE ('PC18')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Planar complex unsigned 18-bit big endian IQ sample
Description #
This format contains a sequence of complex number samples. Each complex number consist of two parts called In-phase and Quadrature (IQ). Both I and Q are represented as a 18 bit unsigned big endian number stored in 32 bit space. The remaining unused bits within the 32 bit space will be padded with 0. I value starts first and Q value starts at an offset equalling half of the buffer size (i.e.) offset = buffersize/2. Out of the 18 bits, bit 17:2 (16 bit) is data and bit 1:0 (2 bit) can be any value.
Byte Order. Each cell is one byte.
|
Offset: |
Byte B0 |
Byte B1 |
Byte B2 |
Byte B3 |
|---|---|---|---|---|
|
start + 0: |
I'0[17:10] |
I'0[9:2] |
I'0[1:0]; B2[5:0]=pad |
pad |
|
start + 4: |
I'1[17:10] |
I'1[9:2] |
I'1[1:0]; B2[5:0]=pad |
pad |
|
... |
||||
|
start + offset: |
Q'0[17:10] |
Q'0[9:2] |
Q'0[1:0]; B2[5:0]=pad |
pad |
|
start + offset + 4: |
Q'1[17:10] |
Q'1[9:2] |
Q'1[1:0]; B2[5:0]=pad |
pad |
V4L2_SDR_FMT_PCU20BE ('PC20')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Planar complex unsigned 20-bit big endian IQ sample
Description #
This format contains a sequence of complex number samples. Each complex number consist of two parts called In-phase and Quadrature (IQ). Both I and Q are represented as a 20 bit unsigned big endian number stored in 32 bit space. The remaining unused bits within the 32 bit space will be padded with 0. I value starts first and Q value starts at an offset equalling half of the buffer size (i.e.) offset = buffersize/2. Out of the 20 bits, bit 19:2 (18 bit) is data and bit 1:0 (2 bit) can be any value.
Byte Order. Each cell is one byte.
|
Offset: |
Byte B0 |
Byte B1 |
Byte B2 |
Byte B3 |
|---|---|---|---|---|
|
start + 0: |
I'0[19:12] |
I'0[11:4] |
I'0[3:0]; B2[3:0]=pad |
pad |
|
start + 4: |
I'1[19:12] |
I'1[11:4] |
I'1[3:0]; B2[3:0]=pad |
pad |
|
... |
||||
|
start + offset: |
Q'0[19:12] |
Q'0[11:4] |
Q'0[3:0]; B2[3:0]=pad |
pad |
|
start + offset + 4: |
Q'1[19:12] |
Q'1[11:4] |
Q'1[3:0]; B2[3:0]=pad |
pad |
V4L2_SDR_FMT_RU12LE ('RU12')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Real unsigned 12-bit little endian sample
Description #
This format contains sequence of real number samples. Each sample is represented as a 12 bit unsigned little endian number. Sample is stored in 16 bit space with unused high bits padded with 0.
Byte Order. Each cell is one byte.
|
start + 0: |
I'0[7:0] |
I'0[11:8] |
V4L2_PIX_FMT_IPU3_SBGGR10 ('ip3b'), V4L2_PIX_FMT_IPU3_SGBRG10 ('ip3g'), V4L2_PIX_FMT_IPU3_SGRBG10 ('ip3G'), V4L2_PIX_FMT_IPU3_SRGGB10 ('ip3r')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
10-bit Bayer formats #
Description #
These four pixel formats are used by Intel IPU3 driver, they are raw sRGB / Bayer formats with 10 bits per sample with every 25 pixels packed to 32 bytes leaving 6 most significant bits padding in the last byte. The format is little endian.
In other respects this format is similar to v4l2-pix-fmt-srggb10. Below is an example of a small image in V4L2_PIX_FMT_IPU3_SBGGR10 format.
Byte Order. Each cell is one byte.
|
start + 0: |
B0000low |
G0001low(bits 7--2) B0000high(bits 1--0) |
B0002low(bits 7--4) G0001high(bits 3--0) |
G0003low(bits 7--6) B0002high(bits 5--0) |
|
start + 4: |
G0003high |
B0004low |
G0005low(bits 7--2) B0004high(bits 1--0) |
B0006low(bits 7--4) G0005high(bits 3--0) |
|
start + 8: |
G0007low(bits 7--6) B0006high(bits 5--0) |
G0007high |
B0008low |
G0009low(bits 7--2) B0008high(bits 1--0) |
|
start + 12: |
B0010low(bits 7--4) G0009high(bits 3--0) |
G0011low(bits 7--6) B0010high(bits 5--0) |
G0011high |
B0012low |
|
start + 16: |
G0013low(bits 7--2) B0012high(bits 1--0) |
B0014low(bits 7--4) G0013high(bits 3--0) |
G0015low(bits 7--6) B0014high(bits 5--0) |
G0015high |
|
start + 20 |
B0016low |
G0017low(bits 7--2) B0016high(bits 1--0) |
B0018low(bits 7--4) G0017high(bits 3--0) |
G0019low(bits 7--6) B0018high(bits 5--0) |
|
start + 24: |
G0019high |
B0020low |
G0021low(bits 7--2) B0020high(bits 1--0) |
B0022low(bits 7--4) G0021high(bits 3--0) |
|
start + 28: |
G0023low(bits 7--6) B0022high(bits 5--0) |
G0023high |
B0024low |
B0024high(bits 1--0) |
|
start + 32: |
G0100low |
R0101low(bits 7--2) G0100high(bits 1--0) |
G0102low(bits 7--4) R0101high(bits 3--0) |
R0103low(bits 7--6) G0102high(bits 5--0) |
|
start + 36: |
R0103high |
G0104low |
R0105low(bits 7--2) G0104high(bits 1--0) |
G0106low(bits 7--4) R0105high(bits 3--0) |
|
start + 40: |
R0107low(bits 7--6) G0106high(bits 5--0) |
R0107high |
G0108low |
R0109low(bits 7--2) G0108high(bits 1--0) |
|
start + 44: |
G0110low(bits 7--4) R0109high(bits 3--0) |
R0111low(bits 7--6) G0110high(bits 5--0) |
R0111high |
G0112low |
|
start + 48: |
R0113low(bits 7--2) G0112high(bits 1--0) |
G0114low(bits 7--4) R0113high(bits 3--0) |
R0115low(bits 7--6) G0114high(bits 5--0) |
R0115high |
|
start + 52: |
G0116low |
R0117low(bits 7--2) G0116high(bits 1--0) |
G0118low(bits 7--4) R0117high(bits 3--0) |
R0119low(bits 7--6) G0118high(bits 5--0) |
|
start + 56: |
R0119high |
G0120low |
R0121low(bits 7--2) G0120high(bits 1--0) |
G0122low(bits 7--4) R0121high(bits 3--0) |
|
start + 60: |
R0123low(bits 7--6) G0122high(bits 5--0) |
R0123high |
G0124low |
G0124high(bits 1--0) |
|
start + 64: |
B0200low |
G0201low(bits 7--2) B0200high(bits 1--0) |
B0202low(bits 7--4) G0201high(bits 3--0) |
G0203low(bits 7--6) B0202high(bits 5--0) |
|
start + 68: |
G0203high |
B0204low |
G0205low(bits 7--2) B0204high(bits 1--0) |
B0206low(bits 7--4) G0205high(bits 3--0) |
|
start + 72: |
G0207low(bits 7--6) B0206high(bits 5--0) |
G0207high |
B0208low |
G0209low(bits 7--2) B0208high(bits 1--0) |
|
start + 76: |
B0210low(bits 7--4) G0209high(bits 3--0) |
G0211low(bits 7--6) B0210high(bits 5--0) |
G0211high |
B0212low |
|
start + 80: |
G0213low(bits 7--2) B0212high(bits 1--0) |
B0214low(bits 7--4) G0213high(bits 3--0) |
G0215low(bits 7--6) B0214high(bits 5--0) |
G0215high |
|
start + 84: |
B0216low |
G0217low(bits 7--2) B0216high(bits 1--0) |
B0218low(bits 7--4) G0217high(bits 3--0) |
G0219low(bits 7--6) B0218high(bits 5--0) |
|
start + 88: |
G0219high |
B0220low |
G0221low(bits 7--2) B0220high(bits 1--0) |
B0222low(bits 7--4) G0221high(bits 3--0) |
|
start + 92: |
G0223low(bits 7--6) B0222high(bits 5--0) |
G0223high |
B0224low |
B0224high(bits 1--0) |
|
start + 96: |
G0300low |
R0301low(bits 7--2) G0300high(bits 1--0) |
G0302low(bits 7--4) R0301high(bits 3--0) |
R0303low(bits 7--6) G0302high(bits 5--0) |
|
start + 100: |
R0303high |
G0304low |
R0305low(bits 7--2) G0304high(bits 1--0) |
G0306low(bits 7--4) R0305high(bits 3--0) |
|
start + 104: |
R0307low(bits 7--6) G0306high(bits 5--0) |
R0307high |
G0308low |
R0309low(bits 7--2) G0308high(bits 1--0) |
|
start + 108: |
G0310low(bits 7--4) R0309high(bits 3--0) |
R0311low(bits 7--6) G0310high(bits 5--0) |
R0311high |
G0312low |
|
start + 112: |
R0313low(bits 7--2) G0312high(bits 1--0) |
G0314low(bits 7--4) R0313high(bits 3--0) |
R0315low(bits 7--6) G0314high(bits 5--0) |
R0315high |
|
start + 116: |
G0316low |
R0317low(bits 7--2) G0316high(bits 1--0) |
G0318low(bits 7--4) R0317high(bits 3--0) |
R0319low(bits 7--6) G0318high(bits 5--0) |
|
start + 120: |
R0319high |
G0320low |
R0321low(bits 7--2) G0320high(bits 1--0) |
G0322low(bits 7--4) R0321high(bits 3--0) |
|
start + 124: |
R0323low(bits 7--6) G0322high(bits 5--0) |
R0323high |
G0324low |
G0324high(bits 1--0) |
V4L2_PIX_FMT_SRGGB10 ('RG10'), V4L2_PIX_FMT_SGRBG10 ('BA10'), V4L2_PIX_FMT_SGBRG10 ('GB10'), V4L2_PIX_FMT_SBGGR10 ('BG10'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
V4L2_PIX_FMT_SGRBG10 V4L2_PIX_FMT_SGBRG10 V4L2_PIX_FMT_SBGGR10 10-bit Bayer formats expanded to 16 bits
Description #
These four pixel formats are raw sRGB / Bayer formats with 10 bits per sample. Each sample is stored in a 16-bit word, with 6 unused high bits filled with zeros. Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating red and blue rows. Bytes are stored in memory in little endian order. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of one of these formats:
Byte Order. Each cell is one byte, the 6 most significant bits in the high bytes are 0.
|
start + 0: |
B00low |
B00high |
G01low |
G01high |
B02low |
B02high |
G03low |
G03high |
|
start + 8: |
G10low |
G10high |
R11low |
R11high |
G12low |
G12high |
R13low |
R13high |
|
start + 16: |
B20low |
B20high |
G21low |
G21high |
B22low |
B22high |
G23low |
G23high |
|
start + 24: |
G30low |
G30high |
R31low |
R31high |
G32low |
G32high |
R33low |
R33high |
V4L2_PIX_FMT_SBGGR10ALAW8 ('aBA8'), V4L2_PIX_FMT_SGBRG10ALAW8 ('aGA8'), V4L2_PIX_FMT_SGRBG10ALAW8 ('agA8'), V4L2_PIX_FMT_SRGGB10ALAW8 ('aRA8'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
V4L2_PIX_FMT_SGBRG10ALAW8 V4L2_PIX_FMT_SGRBG10ALAW8 V4L2_PIX_FMT_SRGGB10ALAW8 10-bit Bayer formats compressed to 8 bits
Description #
These four pixel formats are raw sRGB / Bayer formats with 10 bits per color compressed to 8 bits each, using the A-LAW algorithm. Each color component consumes 8 bits of memory. In other respects this format is similar to V4L2_PIX_FMT_SRGGB8 ('RGGB'), V4L2_PIX_FMT_SGRBG8 ('GRBG'), V4L2_PIX_FMT_SGBRG8 ('GBRG'), V4L2_PIX_FMT_SBGGR8 ('BA81'),.
V4L2_PIX_FMT_SBGGR10DPCM8 ('bBA8'), V4L2_PIX_FMT_SGBRG10DPCM8 ('bGA8'), V4L2_PIX_FMT_SGRBG10DPCM8 ('BD10'), V4L2_PIX_FMT_SRGGB10DPCM8 ('bRA8'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
man V4L2_PIX_FMT_SBGGR10DPCM8(2)
V4L2_PIX_FMT_SGBRG10DPCM8 V4L2_PIX_FMT_SGRBG10DPCM8 V4L2_PIX_FMT_SRGGB10DPCM8 10-bit Bayer formats compressed to 8 bits
Description #
These four pixel formats are raw sRGB / Bayer formats with 10 bits per colour compressed to 8 bits each, using DPCM compression. DPCM, differential pulse-code modulation, is lossy. Each colour component consumes 8 bits of memory. In other respects this format is similar to V4L2_PIX_FMT_SRGGB10 ('RG10'), V4L2_PIX_FMT_SGRBG10 ('BA10'), V4L2_PIX_FMT_SGBRG10 ('GB10'), V4L2_PIX_FMT_SBGGR10 ('BG10'),.
V4L2_PIX_FMT_SRGGB10P ('pRAA'), V4L2_PIX_FMT_SGRBG10P ('pgAA'), V4L2_PIX_FMT_SGBRG10P ('pGAA'), V4L2_PIX_FMT_SBGGR10P ('pBAA'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
V4L2_PIX_FMT_SGRBG10P V4L2_PIX_FMT_SGBRG10P V4L2_PIX_FMT_SBGGR10P 10-bit packed Bayer formats
Description #
These four pixel formats are packed raw sRGB / Bayer formats with 10 bits per sample. Every four consecutive samples are packed into 5 bytes. Each of the first 4 bytes contain the 8 high order bits of the pixels, and the 5th byte contains the 2 least significants bits of each pixel, in the same order.
Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating green-red and green-blue rows. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR10P image:
Byte Order. Each cell is one byte.
|
start + 0: |
B00high |
G01high |
B02high |
G03high |
G03low(bits 7--6) B02low(bits 5--4) G01low(bits 3--2) B00low(bits 1--0) |
|
start + 5: |
G10high |
R11high |
G12high |
R13high |
R13low(bits 7--6) G12low(bits 5--4) R11low(bits 3--2) G10low(bits 1--0) |
|
start + 10: |
B20high |
G21high |
B22high |
G23high |
G23low(bits 7--6) B22low(bits 5--4) G21low(bits 3--2) B20low(bits 1--0) |
|
start + 15: |
G30high |
R31high |
G32high |
R33high |
R33low(bits 7--6) G32low(bits 5--4) R31low(bits 3--2) G30low(bits 1--0) |
V4L2_PIX_FMT_SRGGB12 ('RG12'), V4L2_PIX_FMT_SGRBG12 ('BA12'), V4L2_PIX_FMT_SGBRG12 ('GB12'), V4L2_PIX_FMT_SBGGR12 ('BG12'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
V4L2_PIX_FMT_SGRBG12 V4L2_PIX_FMT_SGBRG12 V4L2_PIX_FMT_SBGGR12 12-bit Bayer formats expanded to 16 bits
Description #
These four pixel formats are raw sRGB / Bayer formats with 12 bits per colour. Each colour component is stored in a 16-bit word, with 4 unused high bits filled with zeros. Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating red and blue rows. Bytes are stored in memory in little endian order. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR12 image:
Byte Order. Each cell is one byte, the 4 most significant bits in the high bytes are 0.
|
start + 0: |
B00low |
B00high |
G01low |
G01high |
B02low |
B02high |
G03low |
G03high |
|
start + 8: |
G10low |
G10high |
R11low |
R11high |
G12low |
G12high |
R13low |
R13high |
|
start + 16: |
B20low |
B20high |
G21low |
G21high |
B22low |
B22high |
G23low |
G23high |
|
start + 24: |
G30low |
G30high |
R31low |
R31high |
G32low |
G32high |
R33low |
R33high |
V4L2_PIX_FMT_SRGGB12P ('pRCC'), V4L2_PIX_FMT_SGRBG12P ('pgCC'), V4L2_PIX_FMT_SGBRG12P ('pGCC'), V4L2_PIX_FMT_SBGGR12P ('pBCC')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
12-bit packed Bayer formats #
Description #
These four pixel formats are packed raw sRGB / Bayer formats with 12 bits per colour. Every two consecutive samples are packed into three bytes. Each of the first two bytes contain the 8 high order bits of the pixels, and the third byte contains the four least significant bits of each pixel, in the same order.
Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating green-red and green-blue rows. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR12P image:
Byte Order. Each cell is one byte.
|
start + 0: |
B00high |
G01high |
G01low(bits 7--4) B00low(bits 3--0) |
B02high |
G03high |
G03low(bits 7--4) B02low(bits 3--0) |
|
start + 6: |
G10high |
R11high |
R11low(bits 7--4) G10low(bits 3--0) |
G12high |
R13high |
R13low(bits 7--4) G12low(bits 3--0) |
|
start + 12: |
B20high |
G21high |
G21low(bits 7--4) B20low(bits 3--0) |
B22high |
G23high |
G23low(bits 7--4) B22low(bits 3--0) |
|
start + 18: |
G30high |
R31high |
R31low(bits 7--4) G30low(bits 3--0) |
G32high |
R33high |
R33low(bits 7--4) G32low(bits 3--0) |
V4L2_PIX_FMT_SRGGB14 ('RG14'), V4L2_PIX_FMT_SGRBG14 ('GR14'), V4L2_PIX_FMT_SGBRG14 ('GB14'), V4L2_PIX_FMT_SBGGR14 ('BG14'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
14-bit Bayer formats expanded to 16 bits #
Description #
These four pixel formats are raw sRGB / Bayer formats with 14 bits per colour. Each sample is stored in a 16-bit word, with two unused high bits filled with zeros. Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating red and blue rows. Bytes are stored in memory in little endian order. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR14 image:
Byte Order. Each cell is one byte, the two most significant bits in the high bytes are zero.
|
start + 0: |
B00low |
B00high |
G01low |
G01high |
B02low |
B02high |
G03low |
G03high |
|
start + 8: |
G10low |
G10high |
R11low |
R11high |
G12low |
G12high |
R13low |
R13high |
|
start + 16: |
B20low |
B20high |
G21low |
G21high |
B22low |
B22high |
G23low |
G23high |
|
start + 24: |
G30low |
G30high |
R31low |
R31high |
G32low |
G32high |
R33low |
R33high |
V4L2_PIX_FMT_SRGGB14P ('pREE'), V4L2_PIX_FMT_SGRBG14P ('pgEE'), V4L2_PIX_FMT_SGBRG14P ('pGEE'), V4L2_PIX_FMT_SBGGR14P ('pBEE'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
man V4L2_PIX_FMT_SRGGB14P(2)
V4L2_PIX_FMT_SGRBG14P V4L2_PIX_FMT_SGBRG14P V4L2_PIX_FMT_SBGGR14P 14-bit packed Bayer formats
Description #
These four pixel formats are packed raw sRGB / Bayer formats with 14 bits per colour. Every four consecutive samples are packed into seven bytes. Each of the first four bytes contain the eight high order bits of the pixels, and the three following bytes contains the six least significant bits of each pixel, in the same order.
Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating green-red and green-blue rows. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of one of these formats:
Byte Order. Each cell is one byte.
|
start + 0 |
B00high |
G01high |
B02high |
G03high |
G01low bits 1--0(bits 7--6) B00low bits 5--0(bits 5--0) |
B02low bits 3--0(bits 7--4) G01low bits 5--2(bits 3--0) |
G03low bits 5--0(bits 7--2) B02low bits 5--4(bits 1--0) |
|
start + 7 |
G10high |
R11high |
G12high |
R13high |
R11low bits 1--0(bits 7--6) G10low bits 5--0(bits 5--0) |
G12low bits 3--0(bits 7--4) R11low bits 5--2(bits 3--0) |
R13low bits 5--0(bits 7--2) G12low bits 5--4(bits 1--0) |
|
start + 14 |
B20high |
G21high |
B22high |
G23high |
G21low bits 1--0(bits 7--6) B20low bits 5--0(bits 5--0) |
B22low bits 3--0(bits 7--4) G21low bits 5--2(bits 3--0) |
G23low bits 5--0(bits 7--2) B22low bits 5--4(bits 1--0) |
|
start + 21 |
G30high |
R31high |
G32high |
R33high |
R31low bits 1--0(bits 7--6) G30low bits 5--0(bits 5--0) |
G32low bits 3--0(bits 7--4) R31low bits 5--2(bits 3--0) |
R33low bits 5--0(bits 7--2) G32low bits 5--4(bits 1--0) |
V4L2_PIX_FMT_SRGGB16 ('RG16'), V4L2_PIX_FMT_SGRBG16 ('GR16'), V4L2_PIX_FMT_SGBRG16 ('GB16'), V4L2_PIX_FMT_SBGGR16 ('BYR2'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
16-bit Bayer formats #
Description #
These four pixel formats are raw sRGB / Bayer formats with 16 bits per sample. Each sample is stored in a 16-bit word. Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating red and blue rows. Bytes are stored in memory in little endian order. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR16 image:
Byte Order. Each cell is one byte.
|
start + 0: |
B00low |
B00high |
G01low |
G01high |
B02low |
B02high |
G03low |
G03high |
|
start + 8: |
G10low |
G10high |
R11low |
R11high |
G12low |
G12high |
R13low |
R13high |
|
start + 16: |
B20low |
B20high |
G21low |
G21high |
B22low |
B22high |
G23low |
G23high |
|
start + 24: |
G30low |
G30high |
R31low |
R31high |
G32low |
G32high |
R33low |
R33high |
V4L2_PIX_FMT_PISP_COMP1_RGGB ('PC1R'), V4L2_PIX_FMT_PISP_COMP1_GRBG ('PC1G'), V4L2_PIX_FMT_PISP_COMP1_GBRG ('PC1g'), V4L2_PIX_FMT_PISP_COMP1_BGGR ('PC1B), V4L2_PIX_FMT_PISP_COMP1_MONO ('PC1M'), V4L2_PIX_FMT_PISP_COMP2_RGGB ('PC2R'), V4L2_PIX_FMT_PISP_COMP2_GRBG ('PC2G'), V4L2_PIX_FMT_PISP_COMP2_GBRG ('PC2g'), V4L2_PIX_FMT_PISP_COMP2_BGGR ('PC2B), V4L2_PIX_FMT_PISP_COMP2_MONO ('PC2M')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Raspberry Pi PiSP compressed 8-bit Bayer formats #
Description #
The Raspberry Pi ISP (PiSP) uses a family of three fixed-rate compressed Bayer formats. A black-level offset may be subtracted to improve compression efficiency; the nominal black level and amount of offset must be signalled out of band. Each scanline is padded to a multiple of 8 pixels wide, and each block of 8 horizontally-contiguous pixels is coded using 8 bytes.
Mode 1 uses a quantization and delta-based coding scheme which preserves up to 12 significant bits. Mode 2 is a simple sqrt-like companding scheme with 6 PWL chords, preserving up to 12 significant bits. Mode 3 combines both companding (with 4 chords) and the delta scheme, preserving up to 14 significant bits.
The remainder of this description applies to Modes 1 and 3.
Each block of 8 pixels is separated into even and odd phases of 4 pixels, coded independently by 32-bit words at successive locations in memory. The two LS bits of each 32-bit word give its "quantization mode".
In quantization mode 0, the lowest 321 quantization levels are multiples of FSD/4096 and the remaining levels are successive multiples of FSD/2048. Quantization modes 1 and 2 use linear quantization with step sizes of FSD/1024 and FSD/512 respectively. Each of the four pixels is quantized independently, with rounding to the nearest level. In quantization mode 2 where the middle two samples have quantized values (q1,q2) both in the range [384..511], they are coded using 9 bits for q1 followed by 7 bits for (q2 & 127). Otherwise, for quantization modes 0, 1 and 2: a 9-bit field encodes MIN(q1,q2) which must be in the range [0..511] and a 7-bit field encodes (q2-q1+64) which must be in [0..127].
Each of the outer samples (q0,q3) is encoded using a 7-bit field based on its inner neighbour q1 or q2. In quantization mode 2 where the inner sample has a quantized value in the range [448..511], the field value is (q0-384). Otherwise for quantization modes 0, 1 and 2: The outer sample is encoded as (q0-MAX(0,q1-64)). q3 is likewise coded based on q2. Each of these values must be in the range [0..127]. All these fields of 2, 9, 7, 7, 7 bits respectively are packed in little-endian order to give a 32-bit word with LE byte order.
Quantization mode 3 has a "7.5-bit" escape, used when none of the above encodings will fit. Each pixel value is quantized to the nearest of 176 levels, where the lowest 95 levels are multiples of FSD/256 and the remaining levels are multiples of FSD/128 (level 175 represents values very close to FSD and may require saturating arithmetic to decode).
Each pair of quantized pixels (q0,q1) or (q2,q3) is jointly coded by a 15-bit field: 2816*(q0>>4) + 16*q1 + (q0&15). Three fields of 2, 15, 15 bits are packed in LE order {15,15,2}.
An implementation of a software decoder of compressed formats is available in Raspberry Pi camera applications code base.
V4L2_PIX_FMT_SRGGB8 ('RGGB'), V4L2_PIX_FMT_SGRBG8 ('GRBG'), V4L2_PIX_FMT_SGBRG8 ('GBRG'), V4L2_PIX_FMT_SBGGR8 ('BA81'),
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
8-bit Bayer formats #
Description #
These four pixel formats are raw sRGB / Bayer formats with 8 bits per sample. Each sample is stored in a byte. Each n-pixel row contains n/2 green samples and n/2 blue or red samples, with alternating red and blue rows. They are conventionally described as GRGR... BGBG..., RGRG... GBGB..., etc. Below is an example of a small V4L2_PIX_FMT_SBGGR8 image:
Byte Order. Each cell is one byte.
|
start + 0: |
B00 |
G01 |
B02 |
G03 |
|
start + 4: |
G10 |
R11 |
G12 |
R13 |
|
start + 8: |
B20 |
G21 |
B22 |
G23 |
|
start + 12: |
G30 |
R31 |
G32 |
R33 |
V4L2_TCH_FMT_DELTA_TD08 ('TD08')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
man V4L2_TCH_FMT_DELTA_TD08(2)
8-bit signed Touch Delta
Description #
This format represents delta data from a touch controller.
Delta values may range from -128 to 127. Typically the values will vary through a small range depending on whether the sensor is touched or not. The full value may be seen if one of the touchscreen nodes has a fault or the line is not connected.
Byte Order. Each cell is one byte.
|
start + 0: |
D'00 |
D'01 |
D'02 |
D'03 |
|
start + 4: |
D'10 |
D'11 |
D'12 |
D'13 |
|
start + 8: |
D'20 |
D'21 |
D'22 |
D'23 |
|
start + 12: |
D'30 |
D'31 |
D'32 |
D'33 |
V4L2_TCH_FMT_DELTA_TD16 ('TD16')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
man V4L2_TCH_FMT_DELTA_TD16(2)
16-bit signed little endian Touch Delta
Description #
This format represents delta data from a touch controller.
Delta values may range from -32768 to 32767. Typically the values will vary through a small range depending on whether the sensor is touched or not. The full value may be seen if one of the touchscreen nodes has a fault or the line is not connected.
Byte Order. Each cell is one byte.
|
start + 0: |
D'00low |
D'00high |
D'01low |
D'01high |
D'02low |
D'02high |
D'03low |
D'03high |
|
start + 8: |
D'10low |
D'10high |
D'11low |
D'11high |
D'12low |
D'12high |
D'13low |
D'13high |
|
start + 16: |
D'20low |
D'20high |
D'21low |
D'21high |
D'22low |
D'22high |
D'23low |
D'23high |
|
start + 24: |
D'30low |
D'30high |
D'31low |
D'31high |
D'32low |
D'32high |
D'33low |
D'33high |
V4L2_TCH_FMT_TU08 ('TU08')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
man V4L2_TCH_FMT_TU08(2)
8-bit unsigned raw touch data
Description #
This format represents unsigned 8-bit data from a touch controller.
This may be used for output for raw and reference data. Values may range from 0 to 255.
Byte Order. Each cell is one byte.
|
start + 0: |
R'00 |
R'01 |
R'02 |
R'03 |
|
start + 4: |
R'10 |
R'11 |
R'12 |
R'13 |
|
start + 8: |
R'20 |
R'21 |
R'22 |
R'23 |
|
start + 12: |
R'30 |
R'31 |
R'32 |
R'33 |
V4L2_TCH_FMT_TU16 ('TU16')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
man V4L2_TCH_FMT_TU16(2)
16-bit unsigned little endian raw touch data
Description #
This format represents unsigned 16-bit data from a touch controller.
This may be used for output for raw and reference data. Values may range from 0 to 65535.
Byte Order. Each cell is one byte.
|
start + 0: |
R'00low |
R'00high |
R'01low |
R'01high |
R'02low |
R'02high |
R'03low |
R'03high |
|
start + 8: |
R'10low |
R'10high |
R'11low |
R'11high |
R'12low |
R'12high |
R'13low |
R'13high |
|
start + 16: |
R'20low |
R'20high |
R'21low |
R'21high |
R'22low |
R'22high |
R'23low |
R'23high |
|
start + 24: |
R'30low |
R'30high |
R'31low |
R'31high |
R'32low |
R'32high |
R'33low |
R'33high |
V4L2_PIX_FMT_UV8 ('UV8')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
UV plane interleaved
Description #
In this format there is no Y plane, Only CbCr plane. ie (UV interleaved)
Byte Order. Each cell is one byte.
|
start + 0: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start + 4: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
|
start + 8: |
Cb20 |
Cr20 |
Cb21 |
Cr21 |
|
start + 12: |
Cb30 |
Cr30 |
Cb31 |
Cr31 |
Multi-planar format structures
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The struct v4l2_plane_pix_format structures define size and layout for each of the planes in a multi-planar format. The struct v4l2_pix_format_mplane structure contains information common to all planes (such as image width and height) and an array of struct v4l2_plane_pix_format structures, describing all planes of that format.
v4l2_plane_pix_format
|
__u32 |
|
Maximum size in bytes required for image data in this plane, set by the driver. When the image consists of variable length compressed data this is the number of bytes required by the codec to support the worst-case compression scenario. The driver will set the value for uncompressed images. Clients are allowed to set the sizeimage field for variable length compressed data flagged with |
|
__u32 |
|
Distance in bytes between the leftmost pixels in two adjacent lines. See struct |
|
__u16 |
|
Reserved for future extensions. Should be zeroed by drivers and applications. |
v4l2_pix_format_mplane
|
__u32 |
|
Image width in pixels. See struct |
|
__u32 |
|
Image height in pixels. See struct |
|
__u32 |
|
The pixel format. Both single- and multi-planar four character codes can be used. |
|
__u32 |
|
Field order, from enum |
|
__u32 |
|
Colorspace encoding, from enum |
|
struct |
|
An array of structures describing format of each plane this pixel format consists of. The number of valid entries in this array has to be put in the |
|
__u8 |
|
Number of planes (i.e. separate memory buffers) for this format and the number of valid entries in the |
|
__u8 |
|
Flags set by the application or driver, see format-flags. |
|
union { |
(anonymous) |
|
|
__u8 |
|
Y'CbCr encoding, from enum |
|
__u8 |
|
HSV encoding, from enum |
|
} |
||
|
__u8 |
|
Quantization range, from enum |
|
__u8 |
|
Transfer function, from enum |
|
__u8 |
|
Reserved for future extensions. Should be zeroed by drivers and applications. |
Single-planar format structure
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
v4l2_pix_format
|
__u32 |
|
Image width in pixels. |
|
__u32 |
|
Image height in pixels. If |
|
Applications set these fields to request an image size, drivers return the closest possible values. In case of planar formats the For compressed formats that contain the resolution information encoded inside the stream, when fed to a stateful mem2mem decoder, the fields may be zero to rely on the decoder to detect the right values. For more details see Memory-to-Memory Stateful Video Decoder Interface and format descriptions. For compressed formats on the CAPTURE side of a stateful mem2mem encoder, the fields must be zero, since the coded size is expected to be calculated internally by the encoder itself, based on the OUTPUT side. For more details see Memory-to-Memory Stateful Video Encoder Interface and format descriptions. |
||
|
__u32 |
|
The pixel format or type of compression, set by the application. This is a little endian four character code. V4L2 defines standard RGB formats in pixfmt-rgb, YUV formats in YUV Formats, and reserved codes in reserved-formats |
|
__u32 |
|
Field order, from enum |
|
__u32 |
|
Distance in bytes between the leftmost pixels in two adjacent lines. |
|
Both applications and drivers can set this field to request padding bytes at the end of each line. Drivers however may ignore the value requested by the application, returning Video hardware may access padding bytes, therefore they must reside in accessible memory. Consider cases where padding bytes after the last line of an image cross a system page boundary. Input devices may write padding bytes, the value is undefined. Output devices ignore the contents of padding bytes. When the image format is planar the For compressed formats the |
||
|
__u32 |
|
Size in bytes of the buffer to hold a complete image, set by the driver. Usually this is The driver will set the value for uncompressed images. Clients are allowed to set the sizeimage field for variable length compressed data flagged with |
|
__u32 |
|
Image colorspace, from enum |
|
__u32 |
|
This field indicates whether the remaining fields of the struct Applications that wish to use the pixel format extended fields must first ensure that the feature is supported by querying the device for the V4L2_CAP_EXT_PIX_FORMAT capability. If the capability isn't set the pixel format extended fields are not supported and using the extended fields will lead to undefined results. To use the extended fields, applications must set the When the |
|
__u32 |
|
Flags set by the application or driver, see format-flags. |
|
union { |
(anonymous) |
|
|
__u32 |
|
Y'CbCr encoding, from enum |
|
__u32 |
|
HSV encoding, from enum |
|
} |
||
|
__u32 |
|
Quantization range, from enum |
|
__u32 |
|
Transfer function, from enum |
|
|
0x00000001 |
The color values are premultiplied by the alpha channel value. For example, if a light blue pixel with 50% transparency was described by RGBA values (128, 192, 255, 128), the same pixel described with premultiplied colors would be described by RGBA values (64, 96, 128, 128) |
|
|
0x00000002 |
Set by the application. It is only used for capture and is ignored for output streams. If set, then request the device to do colorspace conversion from the received colorspace to the requested colorspace values. If the colorimetry field ( To check which conversions are supported by the hardware for the current pixel format, see fmtdesc-flags. |
V4L2_PIX_FMT_Y12I ('Y12I')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Interleaved grey-scale image, e.g. from a stereo-pair
Description #
This is a grey-scale image with a depth of 12 bits per pixel, but with pixels from 2 sources interleaved and bit-packed. Each pixel is stored in a 24-bit word in the little-endian order. On a little-endian machine these pixels can be deinterlaced using
__u8 *buf;
left0 = 0xfff & *buf;
right0 = * >> 4;
Bit-packed representation. pixels cross the byte boundary and have a ratio of 3 bytes for each interleaved pixel.
|
Y'0left[7:0] |
Y'0right[3:0]Y'0left[11:8] |
Y'0right[11:4] |
V4L2_PIX_FMT_Y16I ('Y16I')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Interleaved grey-scale image, e.g. from a stereo-pair
Description #
This is a grey-scale image with a depth of 16 bits per pixel, but with pixels from 2 sources interleaved and unpacked. Each pixel is stored in a 16-bit word in the little-endian order. The first pixel is from the left source.
Pixel unpacked representation. Left/Right pixels 16-bit unpacked - 16-bit for each interleaved pixel.
|
Y'0L[7:0] |
Y'0L[15:8] |
Y'0R[7:0] |
Y'0R[15:8] |
Byte Order. Each cell is one byte.
|
start + 0: |
Y'00Llow |
Y'00Lhigh |
Y'00Rlow |
Y'00Rhigh |
Y'01Llow |
Y'01Lhigh |
Y'01Rlow |
Y'01Rhigh |
|
start + 8: |
Y'10Llow |
Y'10Lhigh |
Y'10Rlow |
Y'10Rhigh |
Y'11Llow |
Y'11Lhigh |
Y'11Rlow |
Y'11Rhigh |
|
start + 16: |
Y'20Llow |
Y'20Lhigh |
Y'20Rlow |
Y'20Rhigh |
Y'21Llow |
Y'21Lhigh |
Y'21Rlow |
Y'21Rhigh |
|
start + 24: |
Y'30Llow |
Y'30Lhigh |
Y'30Rlow |
Y'30Rhigh |
Y'31Llow |
Y'31Lhigh |
Y'31Rlow |
Y'31Rhigh |
V4L2_PIX_FMT_Y8I ('Y8I ')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Interleaved grey-scale image, e.g. from a stereo-pair
Description #
This is a grey-scale image with a depth of 8 bits per pixel, but with pixels from 2 sources interleaved. Each pixel is stored in a 16-bit word. E.g. the R200 RealSense camera stores pixel from the left sensor in lower and from the right sensor in the higher 8 bits.
Byte Order. Each cell is one byte.
|
start + 0: |
Y'00left |
Y'00right |
Y'01left |
Y'01right |
Y'02left |
Y'02right |
Y'03left |
Y'03right |
|
start + 8: |
Y'10left |
Y'10right |
Y'11left |
Y'11right |
Y'12left |
Y'12right |
Y'13left |
Y'13right |
|
start + 16: |
Y'20left |
Y'20right |
Y'21left |
Y'21right |
Y'22left |
Y'22right |
Y'23left |
Y'23right |
|
start + 24: |
Y'30left |
Y'30right |
Y'31left |
Y'31right |
Y'32left |
Y'32right |
Y'33left |
Y'33right |
Luma-Only Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
This family of formats only store the luma component of a Y'CbCr image. They are often referred to as greyscale formats.
|
Identifier |
Code |
Byte 0 |
Byte 1 |
Byte 2 |
Byte 3 |
Byte 4 |
Byte 5 |
Byte 6 |
|---|---|---|---|---|---|---|---|---|
|
|
'GREY' |
Y'0[7:0] |
... |
... |
... |
... |
... |
... |
|
|
'ip3y' |
Y'0[7:0] |
Y'1[5:0] Y'0[9:8] |
Y'2[3:0] Y'1[9:6] |
Y'3[1:0] Y'2[9:4] |
Y'3[9:2] |
... |
... |
|
|
'Y10 ' |
Y'0[7:0] |
|
... |
... |
... |
... |
... |
|
|
'Y10B' |
Y'0[9:2] |
Y'0[1:0] Y'1[9:4] |
Y'1[3:0] Y'2[9:6] |
Y'2[5:0] Y'3[9:8] |
Y'3[7:0] |
... |
... |
|
|
'Y10P' |
Y'0[9:2] |
Y'1[9:2] |
Y'2[9:2] |
Y'3[9:2] |
Y'3[1:0] Y'2[1:0] Y'1[1:0] Y'0[1:0] |
... |
... |
|
|
'Y12 ' |
Y'0[7:0] |
|
... |
... |
... |
... |
... |
|
|
'Y012' |
Y'0[3:0] |
Y'0[11:4] |
... |
... |
... |
... |
... |
|
|
'Y12P' |
Y'0[11:4] |
Y'1[11:4] |
Y'1[3:0] Y'0[3:0] |
... |
... |
... |
... |
|
|
'Y14 ' |
Y'0[7:0] |
|
... |
... |
... |
... |
... |
|
|
'Y14P' |
Y'0[13:6] |
Y'1[13:6] |
Y'2[13:6] |
Y'3[13:6] |
Y'1[1:0] Y'0[5:0] |
Y'2[3:0] Y'1[5:2] |
Y'3[5:0] Y'2[5:4] |
|
|
'Y16 ' |
Y'0[7:0] |
Y'0[15:8] |
... |
... |
... |
... |
... |
|
|
'Y16 ' | (1U << 31) |
Y'0[15:8] |
Y'0[7:0] |
... |
... |
... |
... |
... |
Planar YUV formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Planar formats split luma and chroma data in separate memory regions. They exist in two variants:
-
Semi-planar formats use two planes. The first plane is the luma plane and stores the Y components. The second plane is the chroma plane and stores the Cb and Cr components interleaved.
-
Fully planar formats use three planes to store the Y, Cb and Cr components separately.
Within a plane, components are stored in pixel order, which may be linear or tiled. Padding may be supported at the end of the lines, and the line stride of the chroma planes may be constrained by the line stride of the luma plane.
Some planar formats allow planes to be placed in independent memory locations. They are identified by an 'M' suffix in their name (such as in V4L2_PIX_FMT_NV12M). Those formats are intended to be used only in drivers and applications that support the multi-planar API, described in planar-apis. Unless explicitly documented as supporting non-contiguous planes, formats require the planes to follow each other immediately in memory.
Semi-Planar YUV Formats #
These formats are commonly referred to as NV formats (NV12, NV16, ...). They use two planes, and store the luma components in the first plane and the chroma components in the second plane. The Cb and Cr components are interleaved in the chroma plane, with Cb and Cr always stored in pairs. The chroma order is exposed as different formats.
For memory contiguous formats, the number of padding pixels at the end of the chroma lines is identical to the padding of the luma lines. Without horizontal subsampling, the chroma line stride (in bytes) is thus equal to twice the luma line stride. With horizontal subsampling by 2, the chroma line stride is equal to the luma line stride. Vertical subsampling doesn't affect the line stride.
For non-contiguous formats, no constraints are enforced by the format on the relationship between the luma and chroma line padding and stride.
All components are stored with the same number of bits per component.
|
Identifier |
Code |
Bits per component |
Subsampling |
Chroma order 1 |
Contiguous 2 |
Tiling 3 |
|---|---|---|---|---|---|---|
|
V4L2_PIX_FMT_NV12 |
'NV12' |
8 |
4:2:0 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_NV21 |
'NV21' |
8 |
4:2:0 |
Cr, Cb |
Yes |
Linear |
|
V4L2_PIX_FMT_NV12M |
'NM12' |
8 |
4:2:0 |
Cb, Cr |
No |
Linear |
|
V4L2_PIX_FMT_NV21M |
'NM21' |
8 |
4:2:0 |
Cr, Cb |
No |
Linear |
|
V4L2_PIX_FMT_NV12MT |
'TM12' |
8 |
4:2:0 |
Cb, Cr |
No |
64x32 tiles Horizontal Z order |
|
V4L2_PIX_FMT_NV12MT_16X16 |
'VM12' |
8 |
4:2:2 |
Cb, Cr |
No |
16x16 tiles |
|
V4L2_PIX_FMT_P010 |
'P010' |
10 |
4:2:0 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_P010_4L4 |
'T010' |
10 |
4:2:0 |
Cb, Cr |
Yes |
4x4 tiles |
|
V4L2_PIX_FMT_P012 |
'P012' |
12 |
4:2:0 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_P012M |
'PM12' |
12 |
4:2:0 |
Cb, Cr |
No |
Linear |
|
V4L2_PIX_FMT_NV15 |
'NV15' |
10 |
4:2:0 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_NV15_4L4 |
'VT15' |
15 |
4:2:0 |
Cb, Cr |
Yes |
4x4 tiles |
|
V4L2_PIX_FMT_MT2110T |
'MT2T' |
15 |
4:2:0 |
Cb, Cr |
No |
16x32 / 16x16 tiles tiled low bits |
|
V4L2_PIX_FMT_MT2110R |
'MT2R' |
15 |
4:2:0 |
Cb, Cr |
No |
16x32 / 16x16 tiles raster low bits |
|
V4L2_PIX_FMT_NV16 |
'NV16' |
8 |
4:2:2 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_NV61 |
'NV61' |
8 |
4:2:2 |
Cr, Cb |
Yes |
Linear |
|
V4L2_PIX_FMT_NV16M |
'NM16' |
8 |
4:2:2 |
Cb, Cr |
No |
Linear |
|
V4L2_PIX_FMT_NV61M |
'NM61' |
8 |
4:2:2 |
Cr, Cb |
No |
Linear |
|
V4L2_PIX_FMT_NV20 |
'NV20' |
10 |
4:2:2 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_NV24 |
'NV24' |
8 |
4:4:4 |
Cb, Cr |
Yes |
Linear |
|
V4L2_PIX_FMT_NV42 |
'NV42' |
8 |
4:4:4 |
Cr, Cb |
Yes |
Linear |
[1] Order of chroma samples in the second plane
[2] Indicates if planes have to be contiguous in memory or can be disjoint
[3] Macroblock size in pixels
Color Sample Location: Chroma samples are interstitially sited horizontally.
NV12, NV21, NV12M and NV21M #
Semi-planar YUV 4:2:0 formats. The chroma plane is subsampled by 2 in each direction. Chroma lines contain half the number of pixels and the same number of bytes as luma lines, and the chroma plane contains half the number of lines of the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 16: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start + 20: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
|
start0 + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start0 + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start0 + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start0 + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start1 + 0: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start1 + 4: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
NV15 #
Semi-planar 10-bit YUV 4:2:0 format similar to NV12, using 10-bit components with no padding between each component. A group of 4 components are stored over 5 bytes in little endian order.
|
start + 0: |
Y'00[7:0] |
Y'01[5:0]Y'00[9:8] |
Y'02[3:0]Y'01[9:6] |
Y'03[1:0]Y'02[9:4] |
Y'03[9:2] |
|
start + 5: |
Y'10[7:0] |
Y'11[5:0]Y'10[9:8] |
Y'12[3:0]Y'11[9:6] |
Y'13[1:0]Y'12[9:4] |
Y'13[9:2] |
|
start + 10: |
Y'20[7:0] |
Y'21[5:0]Y'20[9:8] |
Y'22[3:0]Y'21[9:6] |
Y'23[1:0]Y'22[9:4] |
Y'23[9:2] |
|
start + 15: |
Y'30[7:0] |
Y'31[5:0]Y'30[9:8] |
Y'32[3:0]Y'31[9:6] |
Y'33[1:0]Y'32[9:4] |
Y'33[9:2] |
|
start + 20: |
Cb00[7:0] |
Cr00[5:0]Cb00[9:8] |
Cb01[3:0]Cr00[9:6] |
Cr01[1:0]Cb01[9:4] |
Cr01[9:2] |
|
start + 25: |
Cb10[7:0] |
Cr10[5:0]Cb10[9:8] |
Cb11[3:0]Cr10[9:6] |
Cr11[1:0]Cb11[9:4] |
Cr11[9:2] |
Tiled NV12 #
Semi-planar YUV 4:2:0 formats, using macroblock tiling. The chroma plane is subsampled by 2 in each direction. Chroma lines contain half the number of pixels and the same number of bytes as luma lines, and the chroma plane contains half the number of lines of the luma plane. Each tile follows the previous one linearly in memory (from left to right, top to bottom).
V4L2_PIX_FMT_NV12MT_16X16 is similar to V4L2_PIX_FMT_NV12M but stores pixels in 2D 16x16 tiles, and stores tiles linearly in memory. The line stride and image height must be aligned to a multiple of 16. The layouts of the luma and chroma planes are identical.
V4L2_PIX_FMT_NV12MT is similar to V4L2_PIX_FMT_NV12M but stores pixels in 2D 64x32 tiles, and stores 2x2 groups of tiles in Z-order in memory, alternating Z and mirrored Z shapes horizontally. The line stride must be a multiple of 128 pixels to ensure an integer number of Z shapes. The image height must be a multiple of 32 pixels. If the vertical resolution is an odd number of tiles, the last row of tiles is stored in linear order. The layouts of the luma and chroma planes are identical.
V4L2_PIX_FMT_NV12MT macroblock Z shape memory layout
Example V4L2_PIX_FMT_NV12MT memory layout of tiles
V4L2_PIX_FMT_NV12_4L4 stores pixels in 4x4 tiles, and stores tiles linearly in memory. The line stride and image height must be aligned to a multiple of 4. The layouts of the luma and chroma planes are identical.
V4L2_PIX_FMT_NV12_16L16 stores pixels in 16x16 tiles, and stores tiles linearly in memory. The line stride and image height must be aligned to a multiple of 16. The layouts of the luma and chroma planes are identical.
V4L2_PIX_FMT_NV12_32L32 stores pixels in 32x32 tiles, and stores tiles linearly in memory. The line stride and image height must be aligned to a multiple of 32. The layouts of the luma and chroma planes are identical.
V4L2_PIX_FMT_NV12M_8L128 is similar to V4L2_PIX_FMT_NV12M but stores pixels in 2D 8x128 tiles, and stores tiles linearly in memory. The image height must be aligned to a multiple of 128. The layouts of the luma and chroma planes are identical.
V4L2_PIX_FMT_NV12_8L128 is similar to V4L2_PIX_FMT_NV12M_8L128 but stores two planes in one memory.
V4L2_PIX_FMT_MM21 store luma pixel in 16x32 tiles, and chroma pixels in 16x16 tiles. The line stride must be aligned to a multiple of 16 and the image height must be aligned to a multiple of 32. The number of luma and chroma tiles are identical, even though the tile size differ. The image is formed of two non-contiguous planes.
Tiled NV15 #
V4L2_PIX_FMT_NV15_4L4 Semi-planar 10-bit YUV 4:2:0 formats, using 4x4 tiling. All components are packed without any padding between each other. As a side-effect, each group of 4 components are stored over 5 bytes (YYYY or UVUV = 4 * 10 bits = 40 bits = 5 bytes).
V4L2_PIX_FMT_NV12M_10BE_8L128 is similar to V4L2_PIX_FMT_NV12M but stores 10 bits pixels in 2D 8x128 tiles, and stores tiles linearly in memory. the data is arranged in big endian order. The image height must be aligned to a multiple of 128. The layouts of the luma and chroma planes are identical. Note the tile size is 8bytes multiplied by 128 bytes, it means that the low bits and high bits of one pixel may be in different tiles. The 10 bit pixels are packed, so 5 bytes contain 4 10-bit pixels layout like this (for luma): byte 0: Y0(bits 9-2) byte 1: Y0(bits 1-0) Y1(bits 9-4) byte 2: Y1(bits 3-0) Y2(bits 9-6) byte 3: Y2(bits 5-0) Y3(bits 9-8) byte 4: Y3(bits 7-0)
V4L2_PIX_FMT_NV12_10BE_8L128 is similar to V4L2_PIX_FMT_NV12M_10BE_8L128 but stores two planes in one memory.
V4L2_PIX_FMT_MT2110T is one of Mediatek packed 10bit YUV 4:2:0 formats. It is fully packed 10bit 4:2:0 format like NV15 (15 bits per pixel), except that the lower two bits data is stored in separate partitions. The format is composed of 16x32 luma tiles, and 16x16 chroma tiles. Each tiles is 640 bytes long, divided into 8 partitions of 80 bytes. The first 16 bytes of the partition represent the 2 least significant bits of pixel data. The remaining 64 bytes represent the 8 most significant bits of pixel data.
Layout of MT2110T Chroma Tile
Filtering out the upper part of each partitions results in a valid V4L2_PIX_FMT_MM21 frame. A partition is a sub-tile of size 16 x 4. The lower two bits is said to be tiled since each bytes contains the lower two bits of the column of for pixel matching the same index. The chroma tiles only have 4 partitions.
|
start + 0: |
start + 1: |
. . . |
start+15: |
|
|---|---|---|---|---|
|
Bits 1:0 |
Y'0:0 |
Y'0:1 |
. . . |
Y'0:15 |
|
Bit 3:2 |
Y'1:0 |
Y'1:1 |
. . . |
Y'1:15 |
|
Bits 5:4 |
Y'2:0 |
Y'2:1 |
. . . |
Y'2:15 |
|
Bits 7:6 |
Y'3:0 |
Y'3:1 |
. . . |
Y'3:15 |
V4L2_PIX_FMT_MT2110R is identical to V4L2_PIX_FMT_MT2110T except that the least significant two bits layout is in raster order. This means the first byte contains 4 pixels of the first row, with 4 bytes per line.
|
Byte 0 |
... |
Byte 3 |
|||||||
|---|---|---|---|---|---|---|---|---|---|
|
7:6 |
5:4 |
3:2 |
1:0 |
... |
7:6 |
5:4 |
3:2 |
1:0 |
|
|
start + 0: |
Y'0:3 |
Y'0:2 |
Y'0:1 |
Y'0:0 |
... |
Y'0:15 |
Y'0:14 |
Y'0:13 |
Y'0:12 |
|
start + 4: |
Y'1:3 |
Y'1:2 |
Y'1:1 |
Y'1:0 |
... |
Y'1:15 |
Y'1:14 |
Y'1:13 |
Y'1:12 |
|
start + 8: |
Y'2:3 |
Y'2:2 |
Y'2:1 |
Y'2:0 |
... |
Y'2:15 |
Y'2:14 |
Y'2:13 |
Y'2:12 |
|
start+12: |
Y'3:3 |
Y'3:2 |
Y'3:1 |
Y'3:0 |
... |
Y'3:15 |
Y'3:14 |
Y'3:13 |
Y'3:12 |
NV16, NV61, NV16M and NV61M #
Semi-planar YUV 4:2:2 formats. The chroma plane is subsampled by 2 in the horizontal direction. Chroma lines contain half the number of pixels and the same number of bytes as luma lines, and the chroma plane contains the same number of lines as the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 16: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start + 20: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
|
start + 24: |
Cb20 |
Cr20 |
Cb21 |
Cr21 |
|
start + 28: |
Cb30 |
Cr30 |
Cb31 |
Cr31 |
|
start0 + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start0 + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start0 + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start0 + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start1 + 0: |
Cb00 |
Cr00 |
Cb02 |
Cr02 |
|
start1 + 4: |
Cb10 |
Cr10 |
Cb12 |
Cr12 |
|
start1 + 8: |
Cb20 |
Cr20 |
Cb22 |
Cr22 |
|
start1 + 12: |
Cb30 |
Cr30 |
Cb32 |
Cr32 |
NV20 #
Semi-planar 10-bit YUV 4:2:2 format similar to NV16, using 10-bit components with no padding between each component. A group of 4 components are stored over 5 bytes in little endian order.
|
start + 0: |
Y'00[7:0] |
Y'01[5:0]Y'00[9:8] |
Y'02[3:0]Y'01[9:6] |
Y'03[1:0]Y'02[9:4] |
Y'03[9:2] |
|
start + 5: |
Y'10[7:0] |
Y'11[5:0]Y'10[9:8] |
Y'12[3:0]Y'11[9:6] |
Y'13[1:0]Y'12[9:4] |
Y'13[9:2] |
|
start + 10: |
Y'20[7:0] |
Y'21[5:0]Y'20[9:8] |
Y'22[3:0]Y'21[9:6] |
Y'23[1:0]Y'22[9:4] |
Y'23[9:2] |
|
start + 15: |
Y'30[7:0] |
Y'31[5:0]Y'30[9:8] |
Y'32[3:0]Y'31[9:6] |
Y'33[1:0]Y'32[9:4] |
Y'33[9:2] |
|
start + 20: |
Cb00[7:0] |
Cr00[5:0]Cb00[9:8] |
Cb01[3:0]Cr00[9:6] |
Cr01[1:0]Cb01[9:4] |
Cr01[9:2] |
|
start + 25: |
Cb10[7:0] |
Cr10[5:0]Cb10[9:8] |
Cb11[3:0]Cr10[9:6] |
Cr11[1:0]Cb11[9:4] |
Cr11[9:2] |
|
start + 30: |
Cb20[7:0] |
Cr20[5:0]Cb20[9:8] |
Cb21[3:0]Cr20[9:6] |
Cr21[1:0]Cb21[9:4] |
Cr21[9:2] |
|
start + 35: |
Cb30[7:0] |
Cr30[5:0]Cb30[9:8] |
Cb31[3:0]Cr30[9:6] |
Cr31[1:0]Cb31[9:4] |
Cr31[9:2] |
NV24 and NV42 #
Semi-planar YUV 4:4:4 formats. The chroma plane is not subsampled. Chroma lines contain the same number of pixels and twice the number of bytes as luma lines, and the chroma plane contains the same number of lines as the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
||||
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
||||
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
||||
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
||||
|
start + 16: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
Cb02 |
Cr02 |
Cb03 |
Cr03 |
|
start + 24: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
Cb12 |
Cr12 |
Cb13 |
Cr13 |
|
start + 32: |
Cb20 |
Cr20 |
Cb21 |
Cr21 |
Cb22 |
Cr22 |
Cb23 |
Cr23 |
|
start + 40: |
Cb30 |
Cr30 |
Cb31 |
Cr31 |
Cb32 |
Cr32 |
Cb33 |
Cr33 |
P010 and tiled P010 #
P010 is like NV12 with 10 bits per component, expanded to 16 bits. Data in the 10 high bits, zeros in the 6 low bits, arranged in little endian order.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 8: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 16: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 24: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 32: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start + 40: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
P012 and P012M #
P012 is like NV12 with 12 bits per component, expanded to 16 bits. Data in the 12 high bits, zeros in the 4 low bits, arranged in little endian order.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 8: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 16: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 24: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 32: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start + 40: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
|
start0 + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start0 + 8: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start0 + 16: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start0 + 24: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start1 + 0: |
Cb00 |
Cr00 |
Cb01 |
Cr01 |
|
start1 + 8: |
Cb10 |
Cr10 |
Cb11 |
Cr11 |
Fully Planar YUV Formats #
These formats store the Y, Cb and Cr components in three separate planes. The luma plane comes first, and the order of the two chroma planes varies between formats. The two chroma planes always use the same subsampling.
For memory contiguous formats, the number of padding pixels at the end of the chroma lines is identical to the padding of the luma lines. The chroma line stride (in bytes) is thus equal to the luma line stride divided by the horizontal subsampling factor. Vertical subsampling doesn't affect the line stride.
For non-contiguous formats, no constraints are enforced by the format on the relationship between the luma and chroma line padding and stride.
All components are stored with the same number of bits per component.
V4L2_PIX_FMT_P010_4L4 stores pixels in 4x4 tiles, and stores tiles linearly in memory. The line stride must be aligned to multiple of 8 and image height to a multiple of 4. The layouts of the luma and chroma planes are identical.
|
Identifier |
Code |
Bits per component |
Subsampling |
Planes order 4 |
Contiguous 5 |
|---|---|---|---|---|---|
|
V4L2_PIX_FMT_YUV410 |
'YUV9' |
8 |
4:1:0 |
Y, Cb, Cr |
Yes |
|
V4L2_PIX_FMT_YVU410 |
'YVU9' |
8 |
4:1:0 |
Y, Cr, Cb |
Yes |
|
V4L2_PIX_FMT_YUV411P |
'411P' |
8 |
4:1:1 |
Y, Cb, Cr |
Yes |
|
V4L2_PIX_FMT_YUV420M |
'YM12' |
8 |
4:2:0 |
Y, Cb, Cr |
No |
|
V4L2_PIX_FMT_YVU420M |
'YM21' |
8 |
4:2:0 |
Y, Cr, Cb |
No |
|
V4L2_PIX_FMT_YUV420 |
'YU12' |
8 |
4:2:0 |
Y, Cb, Cr |
Yes |
|
V4L2_PIX_FMT_YVU420 |
'YV12' |
8 |
4:2:0 |
Y, Cr, Cb |
Yes |
|
V4L2_PIX_FMT_YUV422P |
'422P' |
8 |
4:2:2 |
Y, Cb, Cr |
Yes |
|
V4L2_PIX_FMT_YUV422M |
'YM16' |
8 |
4:2:2 |
Y, Cb, Cr |
No |
|
V4L2_PIX_FMT_YVU422M |
'YM61' |
8 |
4:2:2 |
Y, Cr, Cb |
No |
|
V4L2_PIX_FMT_YUV444M |
'YM24' |
8 |
4:4:4 |
Y, Cb, Cr |
No |
|
V4L2_PIX_FMT_YVU444M |
'YM42' |
8 |
4:4:4 |
Y, Cr, Cb |
No |
[4] Order of luma and chroma planes
[5] Indicates if planes have to be contiguous in memory or can be disjoint
Color Sample Location: Chroma samples are interstitially sited horizontally.
YUV410 and YVU410 #
Planar YUV 4:1:0 formats. The chroma planes are subsampled by 4 in each direction. Chroma lines contain a quarter of the number of pixels and bytes of the luma lines, and the chroma planes contain a quarter of the number of lines of the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 16: |
Cr00 |
|||
|
start + 17: |
Cb00 |
|||
YUV411P #
Planar YUV 4:1:1 formats. The chroma planes are subsampled by 4 in the horizontal direction. Chroma lines contain a quarter of the number of pixels and bytes of the luma lines, and the chroma planes contain the same number of lines as the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 16: |
Cb00 |
|||
|
start + 17: |
Cb10 |
|||
|
start + 18: |
Cb20 |
|||
|
start + 19: |
Cb30 |
|||
|
start + 20: |
Cr00 |
|||
|
start + 21: |
Cr10 |
|||
|
start + 22: |
Cr20 |
|||
|
start + 23: |
Cr30 |
|||
YUV420, YVU420, YUV420M and YVU420M #
Planar YUV 4:2:0 formats. The chroma planes are subsampled by 2 in each direction. Chroma lines contain half of the number of pixels and bytes of the luma lines, and the chroma planes contain half of the number of lines of the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 16: |
Cr00 |
Cr01 |
||
|
start + 18: |
Cr10 |
Cr11 |
||
|
start + 20: |
Cb00 |
Cb01 |
||
|
start + 22: |
Cb10 |
Cb11 |
||
|
start0 + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start0 + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start0 + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start0 + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start1 + 0: |
Cb00 |
Cb01 |
||
|
start1 + 2: |
Cb10 |
Cb11 |
||
|
start2 + 0: |
Cr00 |
Cr01 |
||
|
start2 + 2: |
Cr10 |
Cr11 |
||
YUV422P, YUV422M and YVU422M #
Planar YUV 4:2:2 formats. The chroma planes are subsampled by 2 in the horizontal direction. Chroma lines contain half of the number of pixels and bytes of the luma lines, and the chroma planes contain the same number of lines as the luma plane.
|
start + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start + 16: |
Cb00 |
Cb01 |
||
|
start + 18: |
Cb10 |
Cb11 |
||
|
start + 20: |
Cb20 |
Cb21 |
||
|
start + 22: |
Cb30 |
Cb31 |
||
|
start + 24: |
Cr00 |
Cr01 |
||
|
start + 26: |
Cr10 |
Cr11 |
||
|
start + 28: |
Cr20 |
Cr21 |
||
|
start + 30: |
Cr30 |
Cr31 |
||
|
start0 + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start0 + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start0 + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start0 + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start1 + 0: |
Cb00 |
Cb01 |
||
|
start1 + 2: |
Cb10 |
Cb11 |
||
|
start1 + 4: |
Cb20 |
Cb21 |
||
|
start1 + 6: |
Cb30 |
Cb31 |
||
|
start2 + 0: |
Cr00 |
Cr01 |
||
|
start2 + 2: |
Cr10 |
Cr11 |
||
|
start2 + 4: |
Cr20 |
Cr21 |
||
|
start2 + 6: |
Cr30 |
Cr31 |
||
YUV444M and YVU444M #
Planar YUV 4:4:4 formats. The chroma planes are no subsampled. Chroma lines contain the same number of pixels and bytes of the luma lines, and the chroma planes contain the same number of lines as the luma plane.
|
start0 + 0: |
Y'00 |
Y'01 |
Y'02 |
Y'03 |
|
start0 + 4: |
Y'10 |
Y'11 |
Y'12 |
Y'13 |
|
start0 + 8: |
Y'20 |
Y'21 |
Y'22 |
Y'23 |
|
start0 + 12: |
Y'30 |
Y'31 |
Y'32 |
Y'33 |
|
start1 + 0: |
Cb00 |
Cb01 |
Cb02 |
Cb03 |
|
start1 + 4: |
Cb10 |
Cb11 |
Cb12 |
Cb13 |
|
start1 + 8: |
Cb20 |
Cb21 |
Cb22 |
Cb23 |
|
start1 + 12: |
Cb20 |
Cb21 |
Cb32 |
Cb33 |
|
start2 + 0: |
Cr00 |
Cr01 |
Cr02 |
Cr03 |
|
start2 + 4: |
Cr10 |
Cr11 |
Cr12 |
Cr13 |
|
start2 + 8: |
Cr20 |
Cr21 |
Cr22 |
Cr23 |
|
start2 + 12: |
Cr30 |
Cr31 |
Cr32 |
Cr33 |
V4L2_PIX_FMT_Z16 ('Z16 ')
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
16-bit depth data with distance values at each pixel
Description #
This is a 16-bit format, representing depth data. Each pixel is a distance to the respective point in the image coordinates. Distance unit can vary and has to be negotiated with the device separately. Each pixel is stored in a 16-bit word in the little endian byte order.
Byte Order. Each cell is one byte.
|
start + 0: |
Z00low |
Z00high |
Z01low |
Z01high |
Z02low |
Z02high |
Z03low |
Z03high |
|
start + 8: |
Z10low |
Z10high |
Z11low |
Z11high |
Z12low |
Z12high |
Z13low |
Z13high |
|
start + 16: |
Z20low |
Z20high |
Z21low |
Z21high |
Z22low |
Z22high |
Z23low |
Z23high |
|
start + 24: |
Z30low |
Z30high |
Z31low |
Z31high |
Z32low |
Z32high |
Z33low |
Z33high |
Image Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The V4L2 API was primarily designed for devices exchanging image data with applications. The struct v4l2_pix_format and struct v4l2_pix_format_mplane structures define the format and layout of an image in memory. The former is used with the single-planar API, while the latter is used with the multi-planar version (see Single- and multi-planar APIs). Image formats are negotiated with the VIDIOC_S_FMT ioctl. (The explanations here focus on video capturing and output, for overlay frame buffer formats see also VIDIOC_G_FBUF.)
Single- and multi-planar APIs
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Some devices require data for each input or output video frame to be placed in discontiguous memory buffers. In such cases, one video frame has to be addressed using more than one memory address, i.e. one pointer per "plane". A plane is a sub-buffer of the current frame. For examples of such formats see Image Formats.
Initially, V4L2 API did not support multi-planar buffers and a set of extensions has been introduced to handle them. Those extensions constitute what is being referred to as the "multi-planar API".
Some of the V4L2 API calls and structures are interpreted differently, depending on whether single- or multi-planar API is being used. An application can choose whether to use one or the other by passing a corresponding buffer type to its ioctl calls. Multi-planar versions of buffer types are suffixed with an _MPLANE string. For a list of available multi-planar buffer types see enum v4l2_buf_type.
Multi-planar formats #
Multi-planar API introduces new multi-planar formats. Those formats use a separate set of FourCC codes. It is important to distinguish between the multi-planar API and a multi-planar format. Multi-planar API calls can handle all single-planar formats as well (as long as they are passed in multi-planar API structures), while the single-planar API cannot handle multi-planar formats.
Calls that distinguish between single and multi-planar APIs #
-
Two additional multi-planar capabilities are added. They can be set together with non-multi-planar ones for devices that handle both single- and multi-planar formats.
-
VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT
New structures for describing multi-planar formats are added: struct
v4l2_pix_format_mplaneand structv4l2_plane_pix_format. Drivers may define new multi-planar formats, which have distinct FourCC codes from the existing single-planar ones. -
VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_QUERYBUF
A new struct
v4l2_planestructure for describing planes is added. Arrays of this structure are passed in the newm.planesfield of structv4l2_buffer. -
Will allocate multi-planar buffers as requested.
Querying Capabilities
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Because V4L2 covers a wide variety of devices not all aspects of the API are equally applicable to all types of devices. Furthermore devices of the same type have different capabilities and this specification permits the omission of a few complicated and less important parts of the API.
The ioctl VIDIOC_QUERYCAP ioctl is available to check if the kernel device is compatible with this specification, and to query the functions and I/O methods supported by the device.
Starting with kernel version 3.1, ioctl VIDIOC_QUERYCAP will return the V4L2 API version used by the driver, with generally matches the Kernel version. There's no need of using ioctl VIDIOC_QUERYCAP to check if a specific ioctl is supported, the V4L2 core now returns ENOTTY if a driver doesn't provide support for an ioctl.
Other features can be queried by calling the respective ioctl, for example ioctl VIDIOC_ENUMINPUT to learn about the number, types and names of video connectors on the device. Although abstraction is a major objective of this API, the ioctl VIDIOC_QUERYCAP ioctl also allows driver specific applications to reliably identify the driver.
All V4L2 drivers must support ioctl VIDIOC_QUERYCAP. Applications should always call this ioctl after opening the device.
Read/Write
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Input and output devices support the read() and write() function, respectively, when the V4L2_CAP_READWRITE flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl is set.
Drivers may need the CPU to copy the data, but they may also support DMA to or from user memory, so this I/O method is not necessarily less efficient than other methods merely exchanging buffer pointers. It is considered inferior though because no meta-information like frame counters or timestamps are passed. This information is necessary to recognize frame dropping and to synchronize with other data streams. However this is also the simplest I/O method, requiring little or no setup to exchange data. It permits command line stunts like this (the vidctrl tool is fictitious):
$ vidctrl /dev/video --input=0 --format=YUYV --size=352x288
$ dd if=/dev/video of=myimage.422 bs=202752 count=1
To read from the device applications use the read() function, to write the write() function. Drivers must implement one I/O method if they exchange data with applications, but it need not be this. 1 When reading or writing is supported, the driver must also support the select() and poll() function. 2
[1] It would be desirable if applications could depend on drivers supporting all I/O interfaces, but as much as the complex memory mapping I/O can be inadequate for some devices we have no reason to require this interface, which is most useful for simple applications capturing still images.
[2] At the driver level select() and poll() are the same, and select() is too important to be optional.
SDR Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
These formats are used for SDR interface only.
Configuration
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Applications can use the selection API to select an area in a video signal or a buffer, and to query for default settings and hardware limits.
Video hardware can have various cropping, composing and scaling limitations. It may only scale up or down, support only discrete scaling factors, or have different scaling abilities in the horizontal and vertical directions. Also it may not support scaling at all. At the same time the cropping/composing rectangles may have to be aligned, and both the source and the sink may have arbitrary upper and lower size limits. Therefore, as usual, drivers are expected to adjust the requested parameters and return the actual values selected. An application can control the rounding behaviour using constraint flags.
Configuration of video capture #
See figure sel-targets-capture for examples of the selection targets available for a video capture device. It is recommended to configure the cropping targets before to the composing targets.
The range of coordinates of the top left corner, width and height of areas that can be sampled is given by the V4L2_SEL_TGT_CROP_BOUNDS target. It is recommended for the driver developers to put the top/left corner at position (0,0). The rectangle's coordinates are expressed in pixels.
The top left corner, width and height of the source rectangle, that is the area actually sampled, is given by the V4L2_SEL_TGT_CROP target. It uses the same coordinate system as V4L2_SEL_TGT_CROP_BOUNDS. The active cropping area must lie completely inside the capture boundaries. The driver may further adjust the requested size and/or position according to hardware limitations.
Each capture device has a default source rectangle, given by the V4L2_SEL_TGT_CROP_DEFAULT target. This rectangle shall cover what the driver writer considers the complete picture. Drivers shall set the active crop rectangle to the default when the driver is first loaded, but not later.
The composing targets refer to a memory buffer. The limits of composing coordinates are obtained using V4L2_SEL_TGT_COMPOSE_BOUNDS. All coordinates are expressed in pixels. The rectangle's top/left corner must be located at position (0,0). The width and height are equal to the image size set by VIDIOC_S_FMT.
The part of a buffer into which the image is inserted by the hardware is controlled by the V4L2_SEL_TGT_COMPOSE target. The rectangle's coordinates are also expressed in the same coordinate system as the bounds rectangle. The composing rectangle must lie completely inside bounds rectangle. The driver must adjust the composing rectangle to fit to the bounding limits. Moreover, the driver can perform other adjustments according to hardware limitations. The application can control rounding behaviour using constraint flags.
For capture devices the default composing rectangle is queried using V4L2_SEL_TGT_COMPOSE_DEFAULT. It is usually equal to the bounding rectangle.
The part of a buffer that is modified by the hardware is given by V4L2_SEL_TGT_COMPOSE_PADDED. It contains all pixels defined using V4L2_SEL_TGT_COMPOSE plus all padding data modified by hardware during insertion process. All pixels outside this rectangle must not be changed by the hardware. The content of pixels that lie inside the padded area but outside active area is undefined. The application can use the padded and active rectangles to detect where the rubbish pixels are located and remove them if needed.
Configuration of video output #
For output devices targets and ioctls are used similarly to the video capture case. The composing rectangle refers to the insertion of an image into a video signal. The cropping rectangles refer to a memory buffer. It is recommended to configure the composing targets before to the cropping targets.
The cropping targets refer to the memory buffer that contains an image to be inserted into a video signal or graphical screen. The limits of cropping coordinates are obtained using V4L2_SEL_TGT_CROP_BOUNDS. All coordinates are expressed in pixels. The top/left corner is always point (0,0). The width and height is equal to the image size specified using VIDIOC_S_FMT ioctl.
The top left corner, width and height of the source rectangle, that is the area from which image date are processed by the hardware, is given by the V4L2_SEL_TGT_CROP. Its coordinates are expressed in the same coordinate system as the bounds rectangle. The active cropping area must lie completely inside the crop boundaries and the driver may further adjust the requested size and/or position according to hardware limitations.
For output devices the default cropping rectangle is queried using V4L2_SEL_TGT_CROP_DEFAULT. It is usually equal to the bounding rectangle.
The part of a video signal or graphics display where the image is inserted by the hardware is controlled by V4L2_SEL_TGT_COMPOSE target. The rectangle's coordinates are expressed in pixels. The composing rectangle must lie completely inside the bounds rectangle. The driver must adjust the area to fit to the bounding limits. Moreover, the driver can perform other adjustments according to hardware limitations.
The device has a default composing rectangle, given by the V4L2_SEL_TGT_COMPOSE_DEFAULT target. This rectangle shall cover what the driver writer considers the complete picture. It is recommended for the driver developers to put the top/left corner at position (0,0). Drivers shall set the active composing rectangle to the default one when the driver is first loaded.
The devices may introduce additional content to video signal other than an image from memory buffers. It includes borders around an image. However, such a padded area is driver-dependent feature not covered by this document. Driver developers are encouraged to keep padded rectangle equal to active one. The padded target is accessed by the V4L2_SEL_TGT_COMPOSE_PADDED identifier. It must contain all pixels from the V4L2_SEL_TGT_COMPOSE target.
Scaling control #
An application can detect if scaling is performed by comparing the width and the height of rectangles obtained using V4L2_SEL_TGT_CROP and V4L2_SEL_TGT_COMPOSE targets. If these are not equal then the scaling is applied. The application can compute the scaling ratios using these values.
Examples
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
(A video capture device is assumed; change V4L2_BUF_TYPE_VIDEO_CAPTURE for other devices; change target to V4L2_SEL_TGT_COMPOSE_* family to configure composing area)
Example: Resetting the cropping parameters #
struct v4l2_selection sel = ;
ret = ;
if
;
sel.target = V4L2_SEL_TGT_CROP;
ret = ;
if
;
Setting a composing area on output of size of at most half of limit placed at a center of a display.
Example: Simple downscaling #
struct v4l2_selection sel = ;
struct v4l2_rect r;
ret = ;
if
;
/* setting smaller compose rectangle */
r.width = sel.r.width / 2;
r.height = sel.r.height / 2;
r.left = sel.r.width / 4;
r.top = sel.r.height / 4;
sel.r = r;
sel.target = V4L2_SEL_TGT_COMPOSE;
sel.flags = V4L2_SEL_FLAG_LE;
ret = ;
if
;
A video output device is assumed; change V4L2_BUF_TYPE_VIDEO_OUTPUT for other devices
Example: Querying for scaling factors #
struct v4l2_selection compose = ;
struct v4l2_selection crop = ;
double hscale, vscale;
ret = ;
if
;
ret = ;
if
;
/* computing scaling factors */
hscale = compose.r.width / crop.r.width;
vscale = compose.r.height / crop.r.height;
Introduction
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Some video capture devices can sample a subsection of a picture and shrink or enlarge it to an image of arbitrary size. Next, the devices can insert the image into larger one. Some video output devices can crop part of an input image, scale it up or down and insert it at an arbitrary scan line and horizontal offset into a video signal. We call these abilities cropping, scaling and composing.
On a video capture device the source is a video signal, and the cropping target determine the area actually sampled. The sink is an image stored in a memory buffer. The composing area specifies which part of the buffer is actually written to by the hardware.
On a video output device the source is an image in a memory buffer, and the cropping target is a part of an image to be shown on a display. The sink is the display or the graphics screen. The application may select the part of display where the image should be displayed. The size and position of such a window is controlled by the compose target.
Rectangles for all cropping and composing targets are defined even if the device does supports neither cropping nor composing. Their size and position will be fixed in such a case. If the device does not support scaling then the cropping and composing rectangles have the same size.
Selection targets
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Cropping and composing targets
Targets used by a cropping, composing and scaling process
See v4l2-selection-targets for more information.
Comparison with old cropping API
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The selection API was introduced to cope with deficiencies of the older CROP API, that was designed to control simple capture devices. Later the cropping API was adopted by video output drivers. The ioctls are used to select a part of the display were the video signal is inserted. It should be considered as an API abuse because the described operation is actually the composing. The selection API makes a clear distinction between composing and cropping operations by setting the appropriate targets.
The CROP API lacks any support for composing to and cropping from an image inside a memory buffer. The application could configure a capture device to fill only a part of an image by abusing V4L2 API. Cropping a smaller image from a larger one is achieved by setting the field bytesperline at struct v4l2_pix_format. Introducing an image offsets could be done by modifying field m_userptr at struct v4l2_buffer before calling VIDIOC_QBUF. Those operations should be avoided because they are not portable (endianness), and do not work for macroblock and Bayer formats and mmap buffers.
The selection API deals with configuration of buffer cropping/composing in a clear, intuitive and portable way. Next, with the selection API the concepts of the padded target and constraints flags are introduced. Finally, struct v4l2_crop and struct v4l2_cropcap have no reserved fields. Therefore there is no way to extend their functionality. The new struct v4l2_selection provides a lot of place for future extensions.
Driver developers are encouraged to implement only selection API. The former cropping API would be simulated using the new one.
Cropping, composing and scaling -- the SELECTION API
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Common selection definitions
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
While the V4L2 selection API and V4L2 subdev selection APIs are very similar, there's one fundamental difference between the two. On sub-device API, the selection rectangle refers to the media bus format, and is bound to a sub-device's pad. On the V4L2 interface the selection rectangles refer to the in-memory pixel format.
This section defines the common definitions of the selection interfaces on the two APIs.
Video Standards
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Video devices typically support one or more different video standards or variations of standards. Each video input and output may support another set of standards. This set is reported by the std field of struct v4l2_input and struct v4l2_output returned by the ioctl VIDIOC_ENUMINPUT and ioctl VIDIOC_ENUMOUTPUT ioctls, respectively.
V4L2 defines one bit for each analog video standard currently in use worldwide, and sets aside bits for driver defined standards, e. g. hybrid standards to watch NTSC video tapes on PAL TVs and vice versa. Applications can use the predefined bits to select a particular standard, although presenting the user a menu of supported standards is preferred. To enumerate and query the attributes of the supported standards applications use the vidioc_enumstd ioctl.
Many of the defined standards are actually just variations of a few major standards. The hardware may in fact not distinguish between them, or do so internal and switch automatically. Therefore enumerated standards also contain sets of one or more standard bits.
Assume a hypothetic tuner capable of demodulating B/PAL, G/PAL and I/PAL signals. The first enumerated standard is a set of B and G/PAL, switched automatically depending on the selected radio frequency in UHF or VHF band. Enumeration gives a "PAL-B/G" or "PAL-I" choice. Similar a Composite input may collapse standards, enumerating "PAL-B/G/H/I", "NTSC-M" and "SECAM-D/K". 1
To query and select the standard used by the current video input or output applications call the VIDIOC_G_STD and VIDIOC_S_STD ioctl, respectively. The received standard can be sensed with the ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD ioctl.
Special rules apply to devices such as USB cameras where the notion of video standards makes little sense. More generally for any capture or output device which is:
-
incapable of capturing fields or frames at the nominal rate of the video standard, or
-
that does not support the video standard formats at all.
Here the driver shall set the std field of struct v4l2_input and struct v4l2_output to zero and the VIDIOC_G_STD, VIDIOC_S_STD, ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD and vidioc_enumstd ioctls shall return the ENOTTY error code or the EINVAL error code.
Applications can make use of the input-capabilities and output-capabilities flags to determine whether the video standard ioctls can be used with the given input or output.
Example: Information about the current video standard #
v4l2_std_id std_id;
struct v4l2_standard standard;
if
;
standard.index = 0;
while
/* EINVAL indicates the end of the enumeration, which cannot be
empty unless this device falls under the USB exception. */
if
Example: Listing the video standards supported by the current input #
struct v4l2_input input;
struct v4l2_standard standard;
;
if
if
;
;
standard.index = 0;
while
/* EINVAL indicates the end of the enumeration, which cannot be
empty unless this device falls under the USB exception. */
if
Example: Selecting a new video standard #
struct v4l2_input input;
v4l2_std_id std_id;
;
if
if
if
/* Note this is also supposed to work when only B
or G/PAL is supported. */
std_id = V4L2_STD_PAL_BG;
if
[1] Some users are already confused by technical terms PAL, NTSC and SECAM. There is no point asking them to distinguish between B, G, D, or K when the software or hardware can do that automatically.
Streaming Parameters
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Streaming parameters are intended to optimize the video capture process as well as I/O. Presently applications can request a high quality capture mode with the VIDIOC_S_PARM ioctl.
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.
Finally 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.
These ioctls are optional, drivers need not implement them. If so, they return the EINVAL error code.
Media Bus Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
v4l2_mbus_framefmt
|
__u32 |
|
Image width in pixels. |
|
__u32 |
|
Image height in pixels. If |
|
__u32 |
|
Format code, from enum v4l2_mbus_pixelcode. |
|
__u32 |
|
Field order, from enum |
|
__u32 |
|
Image colorspace, from enum |
|
union { |
(anonymous) |
|
|
__u16 |
|
Y'CbCr encoding, from enum |
|
__u16 |
|
HSV encoding, from enum |
|
} |
||
|
__u16 |
|
Quantization range, from enum |
|
__u16 |
|
Transfer function, from enum |
|
__u16 |
|
flags See: :ref:v4l2-mbus-framefmt-flags |
|
__u16 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
|
|
0x0001 |
Set by the application. It is only used for source pads and is ignored for sink pads. If set, then request the subdevice to do colorspace conversion from the received colorspace to the requested colorspace values. If the colorimetry field ( To check which conversions are supported by the hardware for the current media bus frame format, see v4l2-subdev-mbus-code-flags. |
Media Bus Pixel Codes #
The media bus pixel codes describe image formats as flowing over physical buses (both between separate physical components and inside SoC devices). This should not be confused with the V4L2 pixel formats that describe, using four character codes, image formats as stored in memory.
While there is a relationship between image formats on buses and image formats in memory (a raw Bayer image won't be magically converted to JPEG just by storing it to memory), there is no one-to-one correspondence between them.
The media bus pixel codes document parallel formats. Should the pixel data be transported over a serial bus, the media bus pixel code that describes a parallel format that transfers a sample on a single clock cycle is used. For instance, both MEDIA_BUS_FMT_BGR888_1X24 and MEDIA_BUS_FMT_BGR888_3X8 are used on parallel busses for transferring an 8 bits per sample BGR data, whereas on serial busses the data in this format is only referred to using MEDIA_BUS_FMT_BGR888_1X24. This is because there is effectively only a single way to transport that format on the serial busses.
Packed RGB Formats #
Those formats transfer pixel data as red, green and blue components. The format code is made of the following information.
-
The red, green and blue components order code, as encoded in a pixel sample. Possible values are RGB and BGR.
-
The number of bits per component, for each component. The values can be different for all components. Common values are 555 and 565.
-
The number of bus samples per pixel. Pixels that are wider than the bus width must be transferred in multiple samples. Common values are 1 and 2.
-
The bus width.
-
For formats where the total number of bits per pixel is smaller than the number of bus samples per pixel times the bus width, a padding value stating if the bytes are padded in their most high order bits (PADHI) or low order bits (PADLO). A "C" prefix is used for component-wise padding in the most high order bits (CPADHI) or low order bits (CPADLO) of each separate component.
-
For formats where the number of bus samples per pixel is larger than 1, an endianness value stating if the pixel is transferred MSB first (BE) or LSB first (LE).
For instance, a format where pixels are encoded as 5-bits red, 5-bits green and 5-bit blue values padded on the high bit, transferred as 2 8-bit samples per pixel with the most significant bits (padding, red and half of the green value) transferred first will be named MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE.
The following tables list existing packed RGB formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_RGB444_1X12 |
0x1016 |
r3 |
r2 |
r1 |
r0 |
g3 |
g2 |
g1 |
g0 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB444_2X8_PADHI_BE |
0x1001 |
0 |
0 |
0 |
0 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||||||||||
|
g3 |
g2 |
g1 |
g0 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB444_2X8_PADHI_LE |
0x1002 |
g3 |
g2 |
g1 |
g0 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||
|
0 |
0 |
0 |
0 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB555_2X8_PADHI_BE |
0x1003 |
0 |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
|||||||||||||||||||||||||
|
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB555_2X8_PADHI_LE |
0x1004 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||
|
0 |
r4 |
r3 |
r2 |
r1 |
r0 |
g4 |
g3 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB565_1X16 |
0x1017 |
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||
|
MEDIA_BUS_FMT_BGR565_2X8_BE |
0x1005 |
b4 |
b3 |
b2 |
b1 |
b0 |
g5 |
g4 |
g3 |
|||||||||||||||||||||||||
|
g2 |
g1 |
g0 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_BGR565_2X8_LE |
0x1006 |
g2 |
g1 |
g0 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||||||||||
|
b4 |
b3 |
b2 |
b1 |
b0 |
g5 |
g4 |
g3 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB565_2X8_BE |
0x1007 |
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
|||||||||||||||||||||||||
|
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB565_2X8_LE |
0x1008 |
g2 |
g1 |
g0 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||
|
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB666_1X18 |
0x1009 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||
|
MEDIA_BUS_FMT_RGB666_2X9_BE |
0x1025 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g5 |
g4 |
g3 |
||||||||||||||||||||||||
|
g2 |
g1 |
g0 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_BGR666_1X18 |
0x1023 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||
|
MEDIA_BUS_FMT_RBG888_1X24 |
0x100e |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||
|
MEDIA_BUS_FMT_RGB666_1X24_CPADHI |
0x1015 |
0 |
0 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
0 |
0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||
|
MEDIA_BUS_FMT_BGR666_1X24_CPADHI |
0x1024 |
0 |
0 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
0 |
0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||
|
MEDIA_BUS_FMT_RGB565_1X24_CPADHI |
0x1022 |
0 |
0 |
0 |
r4 |
r3 |
r2 |
r1 |
r0 |
0 |
0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
0 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||
|
MEDIA_BUS_FMT_BGR888_1X24 |
0x1013 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||
|
MEDIA_BUS_FMT_BGR888_3X8 |
0x101b |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||
|
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||||||||||||||||
|
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_GBR888_1X24 |
0x1014 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||
|
MEDIA_BUS_FMT_RGB888_1X24 |
0x100a |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||
|
MEDIA_BUS_FMT_RGB888_2X12_BE |
0x100b |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g7 |
g6 |
g5 |
g4 |
|||||||||||||||||||||
|
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB888_2X12_LE |
0x100c |
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||
|
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g7 |
g6 |
g5 |
g4 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB888_3X8 |
0x101c |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||||||||||
|
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||||||||||||||||
|
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_RGB666_1X30-CPADLO |
0x101e |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
0 |
0 |
0 |
0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
0 |
0 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
0 |
0 |
0 |
0 |
|||
|
MEDIA_BUS_FMT_RGB888_1X30-CPADLO |
0x101f |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
0 |
0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
0 |
0 |
|||
|
MEDIA_BUS_FMT_ARGB888_1X32 |
0x100d |
a7 |
a6 |
a5 |
a4 |
a3 |
a2 |
a1 |
a0 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|
|
MEDIA_BUS_FMT_RGB888_1X32_PADHI |
0x100f |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
0 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|
|
MEDIA_BUS_FMT_RGB101010_1X30 |
0x1018 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||
The following table list existing packed 36bit wide RGB formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
35 |
34 |
33 |
32 |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_RGB666_1X36_CPADLO |
0x1020 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
0 |
0 |
0 |
0 |
0 |
0 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
0 |
0 |
0 |
0 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
0 |
0 |
0 |
0 |
0 |
0 |
|
|
MEDIA_BUS_FMT_RGB888_1X36_CPADLO |
0x1021 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
0 |
0 |
0 |
0 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
0 |
0 |
0 |
0 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
0 |
0 |
0 |
0 |
|
|
MEDIA_BUS_FMT_RGB121212_1X36 |
0x1019 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|
The following table list existing packed 48bit wide RGB formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
47 |
46 |
45 |
44 |
43 |
42 |
41 |
40 |
39 |
38 |
37 |
36 |
35 |
34 |
33 |
32 |
||||||||||||||||||
|
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|||
|
MEDIA_BUS_FMT_RGB161616_1X48 |
0x101a |
r15 |
r14 |
r13 |
r12 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||||||
|
g15 |
g14 |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b15 |
b14 |
b13 |
b12 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||
The following table list existing packed 60bit wide RGB formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
59 |
58 |
57 |
56 |
55 |
54 |
53 |
52 |
51 |
50 |
49 |
48 |
47 |
46 |
45 |
44 |
43 |
42 |
41 |
40 |
39 |
38 |
37 |
36 |
35 |
34 |
33 |
32 |
||||||
|
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|||
|
MEDIA_BUS_FMT_RGB202020_1X60 |
0x1026 |
r19 |
r18 |
r17 |
r16 |
r15 |
r14 |
r13 |
r12 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
g19 |
g18 |
g17 |
g16 |
g15 |
g14 |
g13 |
g12 |
|||||
|
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
b19 |
b18 |
b17 |
b16 |
b15 |
b14 |
b13 |
b12 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||
On LVDS buses, usually each sample is transferred serialized in seven time slots per pixel clock, on three (18-bit) or four (24-bit) or five (30-bit) differential data pairs at the same time. The remaining bits are used for control signals as defined by SPWG/PSWG/VESA or JEIDA standards. The 24-bit RGB format serialized in seven time slots on four lanes using JEIDA defined bit mapping will be named MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA, for example.
|
Identifier |
Code |
Data organization |
||||||
|---|---|---|---|---|---|---|---|---|
|
Timeslot |
Lane |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_RGB666_1X7X3_SPWG |
0x1010 |
0 |
d |
b1 |
g0 |
|||
|
1 |
d |
b0 |
r5 |
|||||
|
2 |
d |
g5 |
r4 |
|||||
|
3 |
b5 |
g4 |
r3 |
|||||
|
4 |
b4 |
g3 |
r2 |
|||||
|
5 |
b3 |
g2 |
r1 |
|||||
|
6 |
b2 |
g1 |
r0 |
|||||
|
MEDIA_BUS_FMT_RGB888_1X7X4_SPWG |
0x1011 |
0 |
d |
d |
b1 |
g0 |
||
|
1 |
b7 |
d |
b0 |
r5 |
||||
|
2 |
b6 |
d |
g5 |
r4 |
||||
|
3 |
g7 |
b5 |
g4 |
r3 |
||||
|
4 |
g6 |
b4 |
g3 |
r2 |
||||
|
5 |
r7 |
b3 |
g2 |
r1 |
||||
|
6 |
r6 |
b2 |
g1 |
r0 |
||||
|
MEDIA_BUS_FMT_RGB888_1X7X4_JEIDA |
0x1012 |
0 |
d |
d |
b3 |
g2 |
||
|
1 |
b1 |
d |
b2 |
r7 |
||||
|
2 |
b0 |
d |
g7 |
r6 |
||||
|
3 |
g1 |
b7 |
g6 |
r5 |
||||
|
4 |
g0 |
b6 |
g5 |
r4 |
||||
|
5 |
r1 |
b5 |
g4 |
r3 |
||||
|
6 |
r0 |
b4 |
g3 |
r2 |
||||
|
MEDIA_BUS_FMT_RGB101010_1X7X5_SPWG |
0x1026 |
0 |
d |
d |
d |
b1 |
g0 |
|
|
1 |
b9 |
b7 |
d |
b0 |
r5 |
|||
|
2 |
b8 |
b6 |
d |
g5 |
r4 |
|||
|
3 |
g9 |
g7 |
b5 |
g4 |
r3 |
|||
|
4 |
g8 |
g6 |
b4 |
g3 |
r2 |
|||
|
5 |
r9 |
r7 |
b3 |
g2 |
r1 |
|||
|
6 |
r8 |
r6 |
b2 |
g1 |
r0 |
|||
|
MEDIA_BUS_FMT_RGB101010_1X7X5_JEIDA |
0x1027 |
0 |
d |
d |
d |
b5 |
g4 |
|
|
1 |
b1 |
b3 |
d |
b4 |
r9 |
|||
|
2 |
b0 |
b2 |
d |
g9 |
r8 |
|||
|
3 |
g1 |
g3 |
b9 |
g8 |
r7 |
|||
|
4 |
g0 |
g2 |
b8 |
g7 |
r6 |
|||
|
5 |
r1 |
r3 |
b7 |
g6 |
r5 |
|||
|
6 |
r0 |
r2 |
b6 |
g5 |
r4 |
|||
Bayer Formats #
Those formats transfer pixel data as red, green and blue components. The format code is made of the following information.
-
The red, green and blue components order code, as encoded in a pixel sample. The possible values are shown in bayer-patterns.
-
The number of bits per pixel component. All components are transferred on the same number of bits. Common values are 8, 10 and 12.
-
The compression (optional). If the pixel components are ALAW- or DPCM-compressed, a mention of the compression scheme and the number of bits per compressed pixel component.
-
The number of bus samples per pixel. Pixels that are wider than the bus width must be transferred in multiple samples. Common values are 1 and 2.
-
The bus width.
-
For formats where the total number of bits per pixel is smaller than the number of bus samples per pixel times the bus width, a padding value stating if the bytes are padded in their most high order bits (PADHI) or low order bits (PADLO).
-
For formats where the number of bus samples per pixel is larger than 1, an endianness value stating if the pixel is transferred MSB first (BE) or LSB first (LE).
For instance, a format with uncompressed 10-bit Bayer components arranged in a red, green, green, blue pattern transferred as 2 8-bit samples per pixel with the least significant bits transferred first will be named MEDIA_BUS_FMT_SRGGB10_2X8_PADHI_LE.
Bayer Patterns
The following table lists existing packed Bayer formats. The data organization is given as an example for the first pixel only.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_SBGGR8_1X8 |
0x3001 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||
|
MEDIA_BUS_FMT_SGBRG8_1X8 |
0x3013 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||
|
MEDIA_BUS_FMT_SGRBG8_1X8 |
0x3002 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||
|
MEDIA_BUS_FMT_SRGGB8_1X8 |
0x3014 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_ALAW8_1X8 |
0x3015 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||
|
MEDIA_BUS_FMT_SGBRG10_ALAW8_1X8 |
0x3016 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||
|
MEDIA_BUS_FMT_SGRBG10_ALAW8_1X8 |
0x3017 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||
|
MEDIA_BUS_FMT_SRGGB10_ALAW8_1X8 |
0x3018 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_DPCM8_1X8 |
0x300b |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||
|
MEDIA_BUS_FMT_SGBRG10_DPCM8_1X8 |
0x300c |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||
|
MEDIA_BUS_FMT_SGRBG10_DPCM8_1X8 |
0x3009 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||||
|
MEDIA_BUS_FMT_SRGGB10_DPCM8_1X8 |
0x300d |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_BE |
0x3003 |
0 |
0 |
0 |
0 |
0 |
0 |
b9 |
b8 |
|||||||||||||
|
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_2X8_PADHI_LE |
0x3004 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||||
|
0 |
0 |
0 |
0 |
0 |
0 |
b9 |
b8 |
|||||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_BE |
0x3005 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
|||||||||||||
|
b1 |
b0 |
0 |
0 |
0 |
0 |
0 |
0 |
|||||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_2X8_PADLO_LE |
0x3006 |
b1 |
b0 |
0 |
0 |
0 |
0 |
0 |
0 |
|||||||||||||
|
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
|||||||||||||||
|
MEDIA_BUS_FMT_SBGGR10_1X10 |
0x3007 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||||
|
MEDIA_BUS_FMT_SGBRG10_1X10 |
0x300e |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||
|
MEDIA_BUS_FMT_SGRBG10_1X10 |
0x300a |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||||
|
MEDIA_BUS_FMT_SRGGB10_1X10 |
0x300f |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||||
|
MEDIA_BUS_FMT_SBGGR12_1X12 |
0x3008 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||||
|
MEDIA_BUS_FMT_SGBRG12_1X12 |
0x3010 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||
|
MEDIA_BUS_FMT_SGRBG12_1X12 |
0x3011 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||||
|
MEDIA_BUS_FMT_SRGGB12_1X12 |
0x3012 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||||
|
MEDIA_BUS_FMT_SBGGR14_1X14 |
0x3019 |
b13 |
b12 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||||
|
MEDIA_BUS_FMT_SGBRG14_1X14 |
0x301a |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||
|
MEDIA_BUS_FMT_SGRBG14_1X14 |
0x301b |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||||
|
MEDIA_BUS_FMT_SRGGB14_1X14 |
0x301c |
r13 |
r12 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||||
|
MEDIA_BUS_FMT_SBGGR16_1X16 |
0x301d |
b15 |
b14 |
b13 |
b12 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|||||
|
MEDIA_BUS_FMT_SGBRG16_1X16 |
0x301e |
g15 |
g14 |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||
|
MEDIA_BUS_FMT_SGRBG16_1X16 |
0x301f |
g15 |
g14 |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|||||
|
MEDIA_BUS_FMT_SRGGB16_1X16 |
0x3020 |
r15 |
r14 |
r13 |
r12 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|||||
|
MEDIA_BUS_FMT_SBGGR20_1X20 |
0x3021 |
b19 |
b18 |
b17 |
b16 |
b15 |
b14 |
b13 |
b12 |
b11 |
b10 |
b9 |
b8 |
b7 |
b6 |
b5 |
b4 |
b3 |
b2 |
b1 |
b0 |
|
|
MEDIA_BUS_FMT_SGBRG20_1X20 |
0x3022 |
g19 |
g18 |
g17 |
g16 |
g15 |
g14 |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|
|
MEDIA_BUS_FMT_SGRBG20_1X20 |
0x3023 |
g19 |
g18 |
g17 |
g16 |
g15 |
g14 |
g13 |
g12 |
g11 |
g10 |
g9 |
g8 |
g7 |
g6 |
g5 |
g4 |
g3 |
g2 |
g1 |
g0 |
|
|
MEDIA_BUS_FMT_SRGGB20_1X20 |
0x3024 |
r19 |
r18 |
r17 |
r16 |
r15 |
r14 |
r13 |
r12 |
r11 |
r10 |
r9 |
r8 |
r7 |
r6 |
r5 |
r4 |
r3 |
r2 |
r1 |
r0 |
|
Packed YUV Formats #
Those data formats transfer pixel data as (possibly downsampled) Y, U and V components. Some formats include dummy bits in some of their samples and are collectively referred to as "YDYC" (Y-Dummy-Y-Chroma) formats. One cannot rely on the values of these dummy bits as those are undefined.
The format code is made of the following information.
-
The Y, U and V components order code, as transferred on the bus. Possible values are YUYV, UYVY, YVYU and VYUY for formats with no dummy bit, and YDYUYDYV, YDYVYDYU, YUYDYVYD and YVYDYUYD for YDYC formats.
-
The number of bits per pixel component. All components are transferred on the same number of bits. Common values are 8, 10 and 12.
-
The number of bus samples per pixel. Pixels that are wider than the bus width must be transferred in multiple samples. Common values are 0.5 (encoded as 0_5; in this case two pixels are transferred per bus sample), 1, 1.5 (encoded as 1_5) and 2.
-
The bus width. When the bus width is larger than the number of bits per pixel component, several components are packed in a single bus sample. The components are ordered as specified by the order code, with components on the left of the code transferred in the high order bits. Common values are 8 and 16.
For instance, a format where pixels are encoded as 8-bit YUV values downsampled to 4:2:2 and transferred as 2 8-bit bus samples per pixel in the U, Y, V, Y order will be named MEDIA_BUS_FMT_UYVY8_2X8.
v4l2-mbus-pixelcode-yuv8 lists existing packed YUV formats and describes the organization of each pixel data in each sample. When a format pattern is split across multiple samples each of the samples in the pattern is described.
The role of each bit transferred over the bus is identified by one of the following codes.
-
yx for luma component bit number x
-
ux for blue chroma component bit number x
-
vx for red chroma component bit number x
-
ax for alpha component bit number x
-
for non-available bits (for positions higher than the bus width)
-
d for dummy bits
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
10 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_Y8_1X8 |
0x2001 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
MEDIA_BUS_FMT_UV8_1X8 |
0x2015 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_UYVY8_1_5X8 |
0x2002 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_VYUY8_1_5X8 |
0x2003 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_YUYV8_1_5X8 |
0x2004 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_YVYU8_1_5X8 |
0x2005 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_UYVY8_2X8 |
0x2006 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_VYUY8_2X8 |
0x2007 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_YUYV8_2X8 |
0x2008 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_YVYU8_2X8 |
0x2009 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_Y10_1X10 |
0x200a |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_Y10_2X8_PADHI_LE |
0x202c |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
0 |
0 |
0 |
0 |
0 |
0 |
y9 |
y8 |
|||||||||||||||||||||||||||
|
MEDIA_BUS_FMT_UYVY10_2X10 |
0x2018 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
MEDIA_BUS_FMT_VYUY10_2X10 |
0x2019 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
MEDIA_BUS_FMT_YUYV10_2X10 |
0x200b |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||
|
MEDIA_BUS_FMT_YVYU10_2X10 |
0x200c |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||||
|
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||||
|
MEDIA_BUS_FMT_Y12_1X12 |
0x2013 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||
|
MEDIA_BUS_FMT_UYVY12_2X12 |
0x201c |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_VYUY12_2X12 |
0x201d |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_YUYV12_2X12 |
0x201e |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||
|
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_YVYU12_2X12 |
0x201f |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||
|
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||||||
|
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||||||
|
MEDIA_BUS_FMT_Y14_1X14 |
0x202d |
y13 |
y12 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||
|
MEDIA_BUS_FMT_Y16_1X16 |
0x202e |
y15 |
y14 |
y13 |
y12 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||
|
MEDIA_BUS_FMT_UYVY8_1X16 |
0x200f |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||
|
MEDIA_BUS_FMT_VYUY8_1X16 |
0x2010 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||
|
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||||
|
MEDIA_BUS_FMT_YUYV8_1X16 |
0x2011 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||
|
MEDIA_BUS_FMT_YVYU8_1X16 |
0x2012 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||
|
MEDIA_BUS_FMT_YDYUYDYV8_1X16 |
0x2014 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
d |
d |
d |
d |
d |
d |
d |
d |
|||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
d |
d |
d |
d |
d |
d |
d |
d |
|||||||||||||||||||
|
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||
|
MEDIA_BUS_FMT_UYVY10_1X20 |
0x201a |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||
|
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||
|
MEDIA_BUS_FMT_VYUY10_1X20 |
0x201b |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||
|
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||
|
MEDIA_BUS_FMT_YUYV10_1X20 |
0x200d |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||
|
MEDIA_BUS_FMT_YVYU10_1X20 |
0x200e |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||
|
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||
|
MEDIA_BUS_FMT_VUY8_1X24 |
0x201a |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||
|
MEDIA_BUS_FMT_YUV8_1X24 |
0x2025 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||
|
MEDIA_BUS_FMT_UYYVYY8_0_5X24 |
0x2026 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||
|
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||
|
MEDIA_BUS_FMT_UYVY12_1X24 |
0x2020 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||
|
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||
|
MEDIA_BUS_FMT_VYUY12_1X24 |
0x2021 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||
|
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||
|
MEDIA_BUS_FMT_YUYV12_1X24 |
0x2022 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||
|
MEDIA_BUS_FMT_YVYU12_1X24 |
0x2023 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||
|
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||
|
MEDIA_BUS_FMT_YUV10_1X30 |
0x2016 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||
|
MEDIA_BUS_FMT_UYYVYY10_0_5X30 |
0x2027 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||
|
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||
|
MEDIA_BUS_FMT_AYUV8_1X32 |
0x2017 |
a7 |
a6 |
a5 |
a4 |
a3 |
a2 |
a1 |
a0 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|
The following table list existing packed 36bit wide YUV formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
35 |
34 |
33 |
32 |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
10 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_UYYVYY12_0_5X36 |
0x2028 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|
|
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||
|
MEDIA_BUS_FMT_YUV12_1X36 |
0x2029 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|
The following table list existing packed 48bit wide YUV formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
47 |
46 |
45 |
44 |
43 |
42 |
41 |
40 |
39 |
38 |
37 |
36 |
35 |
34 |
33 |
32 |
||||||||||||||||||
|
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
10 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
|||
|
MEDIA_BUS_FMT_YUV16_1X48 |
0x202a |
y15 |
y14 |
y13 |
y12 |
y11 |
y10 |
y8 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||||||||||||||||
|
u15 |
u14 |
u13 |
u12 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
v15 |
v14 |
v13 |
v12 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||
|
MEDIA_BUS_FMT_UYYVYY16_0_5X48 |
0x202b |
u15 |
u14 |
u13 |
u12 |
u11 |
u10 |
u9 |
u8 |
u7 |
u6 |
u5 |
u4 |
u3 |
u2 |
u1 |
u0 |
|||||||||||||||||
|
y15 |
y14 |
y13 |
y12 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y15 |
y14 |
y13 |
y12 |
y11 |
y10 |
y8 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||
|
v15 |
v14 |
v13 |
v12 |
v11 |
v10 |
v9 |
v8 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|||||||||||||||||||
|
y15 |
y14 |
y13 |
y12 |
y11 |
y10 |
y9 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
y15 |
y14 |
y13 |
y12 |
y11 |
y10 |
y8 |
y8 |
y7 |
y6 |
y5 |
y4 |
y3 |
y2 |
y1 |
y0 |
|||
HSV/HSL Formats #
Those formats transfer pixel data as RGB values in a cylindrical-coordinate system using Hue-Saturation-Value or Hue-Saturation-Lightness components. The format code is made of the following information.
-
The hue, saturation, value or lightness and optional alpha components order code, as encoded in a pixel sample. The only currently supported value is AHSV.
-
The number of bits per component, for each component. The values can be different for all components. The only currently supported value is 8888.
-
The number of bus samples per pixel. Pixels that are wider than the bus width must be transferred in multiple samples. The only currently supported value is 1.
-
The bus width.
-
For formats where the total number of bits per pixel is smaller than the number of bus samples per pixel times the bus width, a padding value stating if the bytes are padded in their most high order bits (PADHI) or low order bits (PADLO).
-
For formats where the number of bus samples per pixel is larger than 1, an endianness value stating if the pixel is transferred MSB first (BE) or LSB first (LE).
The following table lists existing HSV/HSL formats.
|
Identifier |
Code |
Data organization |
||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
31 |
30 |
29 |
28 |
27 |
26 |
25 |
24 |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_AHSV8888_1X32 |
0x6001 |
a7 |
a6 |
a5 |
a4 |
a3 |
a2 |
a1 |
a0 |
h7 |
h6 |
h5 |
h4 |
h3 |
h2 |
h1 |
h0 |
s7 |
s6 |
s5 |
s4 |
s3 |
s2 |
s1 |
s0 |
v7 |
v6 |
v5 |
v4 |
v3 |
v2 |
v1 |
v0 |
|
JPEG Compressed Formats #
Those data formats consist of an ordered sequence of 8-bit bytes obtained from JPEG compression process. Additionally to the _JPEG postfix the format code is made of the following information.
-
The number of bus samples per entropy encoded byte.
-
The bus width.
For instance, for a JPEG baseline process and an 8-bit bus width the format will be named MEDIA_BUS_FMT_JPEG_1X8.
The following table lists existing JPEG compressed formats.
|
Identifier |
Code |
Remarks |
|---|---|---|
|
MEDIA_BUS_FMT_JPEG_1X8 |
0x4001 |
Besides of its usage for the parallel bus this format is recommended for transmission of JPEG data over MIPI CSI bus using the User Defined 8-bit Data types. |
Vendor and Device Specific Formats #
This section lists complex data formats that are either vendor or device specific.
The following table lists the existing vendor and device specific formats.
|
Identifier |
Code |
Comments |
|---|---|---|
|
MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8 |
0x5001 |
Interleaved raw UYVY and JPEG image format with embedded meta-data used by Samsung S3C73MX camera sensors. |
Metadata Formats #
This section lists all metadata formats.
The following table lists the existing metadata formats.
|
Identifier |
Code |
Comments |
|---|---|---|
|
MEDIA_BUS_FMT_METADATA_FIXED |
0x7001 |
This format should be used when the same driver handles both sides of the link and the bus format is a fixed metadata format that is not configurable from userspace. Width and height will be set to 0 for this format. |
Generic Serial Metadata Formats #
Generic serial metadata formats are used on serial buses where the actual data content is more or less device specific but the data is transmitted and received by multiple devices that do not process the data in any way, simply writing it to system memory for processing in software at the end of the pipeline.
"b" in an array cell signifies a byte of data, followed by the number of the bit and finally the bit number in subscript. "x" indicates a padding bit.
|
Identifier |
Code |
Data organization within bus Data Unit |
||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Bit |
23 |
22 |
21 |
20 |
19 |
18 |
17 |
16 |
15 |
14 |
13 |
12 |
11 |
10 |
9 |
8 |
7 |
6 |
5 |
4 |
3 |
2 |
1 |
0 |
||
|
MEDIA_BUS_FMT_META_8 |
0x8001 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
|||||||||||||||||
|
MEDIA_BUS_FMT_META_10 |
0x8002 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
x |
x |
|||||||||||||||
|
MEDIA_BUS_FMT_META_12 |
0x8003 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
x |
x |
x |
x |
|||||||||||||
|
MEDIA_BUS_FMT_META_14 |
0x8004 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
x |
x |
x |
x |
x |
x |
|||||||||||
|
MEDIA_BUS_FMT_META_16 |
0x8005 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
x |
x |
x |
x |
x |
x |
x |
x |
|||||||||
|
MEDIA_BUS_FMT_META_20 |
0x8006 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
|||||
|
MEDIA_BUS_FMT_META_24 |
0x8007 |
b07 |
b06 |
b05 |
b04 |
b03 |
b02 |
b01 |
b00 |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
x |
|
Touch Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
These formats are used for Touch Devices interface only.
Tuners and Modulators
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Tuners #
Video input devices can have one or more tuners demodulating a RF signal. Each tuner is associated with one or more video inputs, depending on the number of RF connectors on the tuner. The type field of the respective struct v4l2_input returned by the ioctl VIDIOC_ENUMINPUT ioctl is set to V4L2_INPUT_TYPE_TUNER and its tuner field contains the index number of the tuner.
Radio input devices have exactly one tuner with index zero, no video inputs.
To query and change tuner properties applications use the VIDIOC_G_TUNER and VIDIOC_S_TUNER ioctls, respectively. The struct v4l2_tuner returned by VIDIOC_G_TUNER also contains signal status information applicable when the tuner of the current video or radio input is queried.
Modulators #
Video output devices can have one or more modulators, that modulate a video signal for radiation or connection to the antenna input of a TV set or video recorder. Each modulator is associated with one or more video outputs, depending on the number of RF connectors on the modulator. The type field of the respective struct v4l2_output returned by the ioctl VIDIOC_ENUMOUTPUT ioctl is set to V4L2_OUTPUT_TYPE_MODULATOR and its modulator field contains the index number of the modulator.
Radio output devices have exactly one modulator with index zero, no video outputs.
A video or radio device cannot support both a tuner and a modulator. Two separate device nodes will have to be used for such hardware, one that supports the tuner functionality and one that supports the modulator functionality. The reason is a limitation with the VIDIOC_S_FREQUENCY ioctl where you cannot specify whether the frequency is for a tuner or a modulator.
To query and change modulator properties applications use the VIDIOC_G_MODULATOR and VIDIOC_S_MODULATOR ioctl. Note that VIDIOC_S_MODULATOR does not switch the current modulator, when there is more than one at all. The modulator is solely determined by the current video output. Drivers must support both ioctls and set the V4L2_CAP_MODULATOR flag in the struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl when the device has one or more modulators.
Radio Frequency #
To get and set the tuner or modulator radio frequency applications use the VIDIOC_G_FREQUENCY and VIDIOC_S_FREQUENCY ioctl which both take a pointer to a struct v4l2_frequency. These ioctls are used for TV and radio devices alike. Drivers must support both ioctls when the tuner or modulator ioctls are supported, or when the device is a radio device.
Function Reference
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
- V4L2 close()
- V4L2 ioctl()
- ioctl VIDIOC_CREATE_BUFS
- ioctl VIDIOC_CROPCAP
- ioctl VIDIOC_DBG_G_CHIP_INFO
- ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
- ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD
- ioctl VIDIOC_DQEVENT
- ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP
- ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD
- ioctl VIDIOC_ENUMAUDIO
- ioctl VIDIOC_ENUMAUDOUT
- ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS
- ioctl VIDIOC_ENUM_FMT
- ioctl VIDIOC_ENUM_FRAMESIZES
- ioctl VIDIOC_ENUM_FRAMEINTERVALS
- ioctl VIDIOC_ENUM_FREQ_BANDS
- ioctl VIDIOC_ENUMINPUT
- ioctl VIDIOC_ENUMOUTPUT
- vidioc-enumstd
- ioctl VIDIOC_EXPBUF
- ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO
- ioctl VIDIOC_G_AUDOUT, VIDIOC_S_AUDOUT
- ioctl VIDIOC_G_CROP, VIDIOC_S_CROP
- ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
- ioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS
- ioctl VIDIOC_G_EDID, VIDIOC_S_EDID, VIDIOC_SUBDEV_G_EDID, VIDIOC_SUBDEV_S_EDID
- ioctl VIDIOC_G_ENC_INDEX
- vidioc-g-ext-ctrls
- ioctl VIDIOC_G_FBUF, VIDIOC_S_FBUF
- ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT
- ioctl VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY
- ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT
- ioctl VIDIOC_G_JPEGCOMP, VIDIOC_S_JPEGCOMP
- ioctl VIDIOC_G_MODULATOR, VIDIOC_S_MODULATOR
- ioctl VIDIOC_G_OUTPUT, VIDIOC_S_OUTPUT
- ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
- ioctl VIDIOC_G_PRIORITY, VIDIOC_S_PRIORITY
- ioctl VIDIOC_G_SELECTION, VIDIOC_S_SELECTION
- vidioc-g-sliced-vbi-cap
- ioctl VIDIOC_G_STD, VIDIOC_S_STD, VIDIOC_SUBDEV_G_STD, VIDIOC_SUBDEV_S_STD
- vidioc-g-tuner
- ioctl VIDIOC_LOG_STATUS
- ioctl VIDIOC_OVERLAY
- ioctl VIDIOC_PREPARE_BUF
- ioctl VIDIOC_QBUF, VIDIOC_DQBUF
- ioctl VIDIOC_QUERYBUF
- ioctl VIDIOC_QUERYCAP
- vidioc-queryctrl
- ioctl VIDIOC_QUERY_DV_TIMINGS
- ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD
- vidioc-reqbufs
- ioctl VIDIOC_REMOVE_BUFS
- ioctl VIDIOC_S_HW_FREQ_SEEK
- ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF
- ioctl VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL
- ioctl VIDIOC_SUBDEV_ENUM_FRAME_SIZE
- vidioc-subdev-enum-mbus-code
- ioctl VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP
- ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
- ioctl VIDIOC_SUBDEV_G_FRAME_INTERVAL, VIDIOC_SUBDEV_S_FRAME_INTERVAL
- ioctl VIDIOC_SUBDEV_G_ROUTING, VIDIOC_SUBDEV_S_ROUTING
- ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION
- ioctl VIDIOC_SUBDEV_G_CLIENT_CAP, VIDIOC_SUBDEV_S_CLIENT_CAP
- ioctl VIDIOC_SUBDEV_QUERYCAP
- ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT
- V4L2 mmap()
- V4L2 munmap()
- V4L2 open()
- V4L2 poll()
- V4L2 read()
- V4L2 select()
- V4L2 write()
Streaming I/O (User Pointers)
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Input and output devices support this I/O method when the V4L2_CAP_STREAMING flag in the capabilities field of struct v4l2_capability returned by the ioctl VIDIOC_QUERYCAP ioctl is set. If the particular user pointer method (not only memory mapping) is supported must be determined by calling the vidioc_reqbufs ioctl with the memory type set to V4L2_MEMORY_USERPTR.
This I/O method combines advantages of the read/write and memory mapping methods. Buffers (planes) are allocated by the application itself, and can reside for example in virtual or shared memory. Only pointers to data are exchanged, these pointers and meta-information are passed in struct v4l2_buffer (or in struct v4l2_plane in the multi-planar API case). The driver must be switched into user pointer I/O mode by calling the vidioc_reqbufs with the desired buffer type. No buffers (planes) are allocated beforehand, consequently they are not indexed and cannot be queried like mapped buffers with the VIDIOC_QUERYBUF ioctl.
Example: Initiating streaming I/O with user pointers #
struct v4l2_requestbuffers reqbuf;
;
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
reqbuf.memory = V4L2_MEMORY_USERPTR;
if
Buffer (plane) addresses and sizes are passed on the fly with the VIDIOC_QBUF ioctl. Although buffers are commonly cycled, applications can pass different addresses and sizes at each VIDIOC_QBUF call. If required by the hardware the driver swaps memory pages within physical memory to create a continuous area of memory. This happens transparently to the application in the virtual memory subsystem of the kernel. When buffer pages have been swapped out to disk they are brought back and finally locked in physical memory for DMA. 1
Filled or displayed buffers are dequeued with the VIDIOC_DQBUF ioctl. The driver can unlock the memory pages at any time between the completion of the DMA and this ioctl. The memory is also unlocked when VIDIOC_STREAMOFF is called, vidioc_reqbufs, or when the device is closed. Applications must take care not to free buffers without dequeuing. Firstly, the buffers remain locked for longer, wasting physical memory. Secondly the driver will not be notified when the memory is returned to the application's free list and subsequently reused for other purposes, possibly completing the requested DMA and overwriting valuable data.
For capturing applications it is customary to enqueue a number of empty buffers, to start capturing and enter the read loop. Here the application waits until a filled buffer can be dequeued, and re-enqueues the buffer when the data is no longer needed. Output applications fill and enqueue buffers, when enough buffers are stacked up output is started. In the write loop, when the application runs out of free buffers it must wait until an empty buffer can be dequeued and reused. Two methods exist to suspend execution of the application until one or more buffers can be dequeued. By default VIDIOC_DQBUF blocks when no buffer is in the outgoing queue. When the O_NONBLOCK flag was given to the open() function, VIDIOC_DQBUF returns immediately with an EAGAIN error code when no buffer is available. The select() or poll() function are always available.
To start and stop capturing or output applications call the VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctl.
Drivers implementing user pointer I/O must support the VIDIOC_REQBUFS, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctls, the select() and poll() function. 2
[1] We expect that frequently used buffers are typically not swapped out. Anyway, the process of swapping, locking or generating scatter-gather lists may be time consuming. The delay can be masked by the depth of the incoming buffer queue, and perhaps by maintaining caches assuming a buffer will be soon enqueued again. On the other hand, to optimize memory usage drivers can limit the number of buffers locked in advance and recycle the most recently used buffers first. Of course, the pages of empty buffers in the incoming queue need not be saved to disk. Output buffers must be saved on the incoming and outgoing queue because an application may share them with other processes.
[2] At the driver level select() and poll() are the same, and select() is too important to be optional. The rest should be evident.
Generic V4L2 ISP formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Generic ISP formats are metadata formats that define a mechanism to pass ISP parameters and statistics between userspace and drivers in V4L2 buffers. They are designed to allow extending them in a backward-compatible way.
ISP parameters #
The generic ISP configuration parameters format is realized by a defining a single C structure that contains a header, followed by a binary buffer where userspace programs a variable number of ISP configuration data block, one for each supported ISP feature.
The v4l2_isp_params_buffer structure defines the buffer header which is followed by a binary buffer of ISP configuration data. Userspace shall correctly populate the buffer header with the generic parameters format version and with the size (in bytes) of the binary data buffer where it will store the ISP blocks configuration.
Each ISP configuration block is preceded by an header implemented by the v4l2_isp_params_block_header structure, followed by the configuration parameters for that specific block, defined by the ISP driver specific data types.
Userspace applications are responsible for correctly populating each block's header fields (type, flags and size) and the block-specific parameters.
ISP block enabling, disabling and configuration #
When userspace wants to configure and enable an ISP block it shall fully populate the block configuration and set the V4L2_ISP_PARAMS_FL_BLOCK_ENABLE bit in the block header's flags field.
When userspace simply wants to disable an ISP block the V4L2_ISP_PARAMS_FL_BLOCK_DISABLE bit should be set in block header's flags field. Drivers accept a configuration parameters block with no additional data after the header in this case.
If the configuration of an already active ISP block has to be updated, userspace shall fully populate the ISP block parameters and omit setting the V4L2_ISP_PARAMS_FL_BLOCK_ENABLE and V4L2_ISP_PARAMS_FL_BLOCK_DISABLE bits in the header's flags field.
Setting both the V4L2_ISP_PARAMS_FL_BLOCK_ENABLE and V4L2_ISP_PARAMS_FL_BLOCK_DISABLE bits in the flags field is not allowed and returns an error.
Extension to the parameters format can be implemented by adding new blocks definition without invalidating the existing ones.
ISP statistics #
Support for generic statistics format is not yet implemented in Video4Linux2.
V4L2 ISP uAPI data types #
enum v4l2_isp_params_version #
V4L2 ISP parameters versioning
Constants
V4L2_ISP_PARAMS_VERSION_V0: First version of the V4L2 ISP parameters format (for compatibility)V4L2_ISP_PARAMS_VERSION_V1: First version of the V4L2 ISP parameters format
Description
V0 and V1 are identical in order to support drivers compatible with the V4L2 ISP parameters format already upstreamed which use either 0 or 1 as their versioning identifier. Both V0 and V1 refers to the first version of the V4L2 ISP parameters format.
Future revisions of the V4L2 ISP parameters format should start from the value of 2.
struct v4l2_isp_params_block_header #
V4L2 extensible parameters block header
Definition
;
Members
type: The parameters block type (driver-specific)flags: A bitmask of block flags (driver-specific)size: Size (in bytes) of the parameters block, including this header
Description
This structure represents the common part of all the ISP configuration blocks. Each parameters block shall embed an instance of this structure type as its first member, followed by the block-specific configuration data.
The type field is an ISP driver-specific value that identifies the block type. The size field specifies the size of the parameters block.
The flags field is a bitmask of per-block flags V4L2_PARAMS_ISP_FL_* and driver-specific flags specified by the driver header.
struct v4l2_isp_params_buffer #
V4L2 extensible parameters configuration
Definition
;
Members
version: The parameters buffer version (driver-specific)data_size: The configuration data effective size, excluding this headerdata: The configuration data
Description
This structure contains the configuration parameters of the ISP algorithms,
serialized by userspace into a data buffer. Each configuration parameter
block is represented by a block-specific structure which contains a
v4l2_isp_params_block_header entry as first member. Userspace
populates the data buffer with configuration parameters for the blocks that
it intends to configure. As a consequence, the data buffer effective size
changes according to the number of ISP blocks that userspace intends to
configure and is set by userspace in the data_size field.
The parameters buffer is versioned by the version field to allow modifying and extending its definition. Userspace shall populate the version field to inform the driver about the version it intends to use. The driver will parse and handle the data buffer according to the data layout specific to the indicated version and return an error if the desired version is not supported.
For each ISP block that userspace wants to configure, a block-specific structure is appended to the data buffer, one after the other without gaps in between. Userspace shall populate the data_size field with the effective size, in bytes, of the data buffer.
Selection flags
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
|
Flag name |
id |
Definition |
Valid for V4L2 |
Valid for V4L2 subdev |
|---|---|---|---|---|
|
|
(1 << 0) |
Suggest the driver it should choose greater or equal rectangle (in size) than was requested. Albeit the driver may choose a lesser size, it will only do so due to hardware limitations. Without this flag (and |
Yes |
Yes |
|
|
(1 << 1) |
Suggest the driver it should choose lesser or equal rectangle (in size) than was requested. Albeit the driver may choose a greater size, it will only do so due to hardware limitations. |
Yes |
Yes |
|
|
(1 << 2) |
The configuration must not be propagated to any further processing steps. If this flag is not given, the configuration is propagated inside the subdevice to all further processing steps. |
No |
Yes |
Selection targets
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
The precise meaning of the selection targets may be dependent on which of the two interfaces they are used.
|
Target name |
id |
Definition |
Valid for V4L2 |
Valid for V4L2 subdev |
|---|---|---|---|---|
|
|
0x0000 |
Crop rectangle. Defines the cropped area. |
Yes |
Yes |
|
|
0x0001 |
Suggested cropping rectangle that covers the "whole picture". This includes only active pixels and excludes other non-active pixels such as black pixels. |
Yes |
Yes |
|
|
0x0002 |
Bounds of the crop rectangle. All valid crop rectangles fit inside the crop bounds rectangle. |
Yes |
Yes |
|
|
0x0003 |
The native size of the device, e.g. a sensor's pixel array. |
Yes |
Yes |
|
|
0x0100 |
Compose rectangle. Used to configure scaling and composition. |
Yes |
Yes |
|
|
0x0101 |
Suggested composition rectangle that covers the "whole picture". |
Yes |
No |
|
|
0x0102 |
Bounds of the compose rectangle. All valid compose rectangles fit inside the compose bounds rectangle. |
Yes |
Yes |
|
|
0x0103 |
The active area and all padding pixels that are inserted or modified by hardware. |
Yes |
No |
Part I - Video for Linux API
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
This part describes the Video for Linux API version 2 (V4L2 API) specification.
Revision 4.5
Table of Contents
- Common API Elements
- Image Formats
- Input/Output
- Interfaces
- Libv4l Userspace Library
- Changes
- Function Reference
- Common definitions for V4L2 and V4L2 subdev interfaces
- videodev
- Video Capture Example
- Video Grabber example using libv4l
- References
Revision and Copyright #
Authors, in alphabetical order:
-
Ailus, Sakari <sakari.ailus@iki.fi>
- Subdev selections API.
-
Carvalho Chehab, Mauro <mchehab+samsung@kernel.org>
- Documented libv4l, designed and added v4l2grab example, Remote Controller chapter.
-
Dirks, Bill
- Original author of the V4L2 API and documentation.
-
Figa, Tomasz <tfiga@chromium.org>
-
Documented the memory-to-memory decoder interface.
-
Documented the memory-to-memory encoder interface.
-
-
H Schimek, Michael <mschimek@gmx.at>
- Original author of the V4L2 API and documentation.
-
Karicheri, Muralidharan <m-karicheri2@ti.com>
- Documented the Digital Video timings API.
-
Osciak, Pawel <posciak@chromium.org>
-
Documented the memory-to-memory decoder interface.
-
Documented the memory-to-memory encoder interface.
-
-
Osciak, Pawel <pawel@osciak.com>
- Designed and documented the multi-planar API.
-
Palosaari, Antti <crope@iki.fi>
- SDR API.
-
Ribalda, Ricardo
- Introduce HSV formats and other minor changes.
-
Rubli, Martin
- Designed and documented the VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS ioctls.
-
Walls, Andy <awalls@md.metrocast.net>
- Documented the fielded V4L2_MPEG_STREAM_VBI_FMT_IVTV MPEG stream embedded, sliced VBI data format in this specification.
-
Verkuil, Hans <hverkuil@kernel.org>
- Designed and documented the VIDIOC_LOG_STATUS ioctl, the extended control ioctls, major parts of the sliced VBI API, the MPEG encoder and decoder APIs and the DV Timings API.
Copyright © 1999-2018: Bill Dirks, Michael H. Schimek, Hans Verkuil, Martin Rubli, Andy Walls, Muralidharan Karicheri, Mauro Carvalho Chehab, Pawel Osciak, Sakari Ailus & Antti Palosaari, Tomasz Figa
Except when explicitly stated as GPL, programming examples within this part can be used and distributed without restrictions.
Revision History #
revision: 4.10 / 2016-07-15 (rr)
Introduce HSV formats.
revision: 4.5 / 2015-10-29 (rr)
Extend VIDIOC_G_EXT_CTRLS;. Replace ctrl_class with a new union with ctrl_class and which. Which is used to select the current value of the control or the default value.
revision: 4.4 / 2015-05-26 (ap)
Renamed V4L2_TUNER_ADC to V4L2_TUNER_SDR. Added V4L2_CID_RF_TUNER_RF_GAIN control. Added transmitter support for Software Defined Radio (SDR) Interface.
revision: 4.1 / 2015-02-13 (mcc)
Fix documentation for media controller device nodes and add support for DVB device nodes. Add support for Tuner sub-device.
revision: 3.19 / 2014-12-05 (hv)
Rewrote Colorspace chapter, added new enum v4l2_ycbcr_encoding and enum v4l2_quantization fields to struct v4l2_pix_format, struct v4l2_pix_format_mplane and struct v4l2_mbus_framefmt.
revision: 3.17 / 2014-08-04 (lp, hv)
Extended struct v4l2_pix_format. Added format flags. Added compound control types and VIDIOC_QUERY_EXT_CTRL.
revision: 3.15 / 2014-02-03 (hv, ap)
Update several sections of "Common API Elements": "Opening and Closing Devices" "Querying Capabilities", "Application Priority", "Video Inputs and Outputs", "Audio Inputs and Outputs" "Tuners and Modulators", "Video Standards" and "Digital Video (DV) Timings". Added SDR API.
revision: 3.14 / 2013-11-25 (rr)
Set width and height as unsigned on v4l2_rect.
revision: 3.11 / 2013-05-26 (hv)
Remove obsolete VIDIOC_DBG_G_CHIP_IDENT ioctl.
revision: 3.10 / 2013-03-25 (hv)
Remove obsolete and unused DV_PRESET ioctls: VIDIOC_G_DV_PRESET, VIDIOC_S_DV_PRESET, VIDIOC_QUERY_DV_PRESET and VIDIOC_ENUM_DV_PRESET. Remove the related v4l2_input/output capability flags V4L2_IN_CAP_PRESETS and V4L2_OUT_CAP_PRESETS. Added VIDIOC_DBG_G_CHIP_INFO.
revision: 3.9 / 2012-12-03 (sa, sn)
Added timestamp types to v4l2_buffer. Added V4L2_EVENT_CTRL_CH_RANGE control event changes flag.
revision: 3.6 / 2012-07-02 (hv)
Added VIDIOC_ENUM_FREQ_BANDS.
revision: 3.5 / 2012-05-07 (sa, sn, hv)
Added V4L2_CTRL_TYPE_INTEGER_MENU and V4L2 subdev selections API. Improved the description of V4L2_CID_COLORFX control, added V4L2_CID_COLORFX_CBCR control. Added camera controls V4L2_CID_AUTO_EXPOSURE_BIAS, V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE, V4L2_CID_IMAGE_STABILIZATION, V4L2_CID_ISO_SENSITIVITY, V4L2_CID_ISO_SENSITIVITY_AUTO, V4L2_CID_EXPOSURE_METERING, V4L2_CID_SCENE_MODE, V4L2_CID_3A_LOCK, V4L2_CID_AUTO_FOCUS_START, V4L2_CID_AUTO_FOCUS_STOP, V4L2_CID_AUTO_FOCUS_STATUS and V4L2_CID_AUTO_FOCUS_RANGE. Added VIDIOC_ENUM_DV_TIMINGS, VIDIOC_QUERY_DV_TIMINGS and VIDIOC_DV_TIMINGS_CAP.
revision: 3.4 / 2012-01-25 (sn)
Added JPEG compression control class.
revision: 3.3 / 2012-01-11 (hv)
Added device_caps field to struct v4l2_capabilities.
revision: 3.2 / 2011-08-26 (hv)
Added V4L2_CTRL_FLAG_VOLATILE.
revision: 3.1 / 2011-06-27 (mcc, po, hv)
Documented that VIDIOC_QUERYCAP now returns a per-subsystem version instead of a per-driver one. Standardize an error code for invalid ioctl. Added V4L2_CTRL_TYPE_BITMASK.
revision: 2.6.39 / 2011-03-01 (mcc, po)
Removed VIDIOC_*_OLD from videodev2.h header and update it to reflect latest changes. Added the multi-planar API.
revision: 2.6.37 / 2010-08-06 (hv)
Removed obsolete vtx (videotext) API.
revision: 2.6.33 / 2009-12-03 (mk)
Added documentation for the Digital Video timings API.
revision: 2.6.32 / 2009-08-31 (mcc)
Now, revisions will match the kernel version where the V4L2 API changes will be used by the Linux Kernel. Also added Remote Controller chapter.
revision: 0.29 / 2009-08-26 (ev)
Added documentation for string controls and for FM Transmitter controls.
revision: 0.28 / 2009-08-26 (gl)
Added V4L2_CID_BAND_STOP_FILTER documentation.
revision: 0.27 / 2009-08-15 (mcc)
Added libv4l and Remote Controller documentation; added v4l2grab and keytable application examples.
revision: 0.26 / 2009-07-23 (hv)
Finalized the RDS capture API. Added modulator and RDS encoder capabilities. Added support for string controls.
revision: 0.25 / 2009-01-18 (hv)
Added pixel formats VYUY, NV16 and NV61, and changed the debug ioctls VIDIOC_DBG_G/S_REGISTER and VIDIOC_DBG_G_CHIP_IDENT. Added camera controls V4L2_CID_ZOOM_ABSOLUTE, V4L2_CID_ZOOM_RELATIVE, V4L2_CID_ZOOM_CONTINUOUS and V4L2_CID_PRIVACY.
revision: 0.24 / 2008-03-04 (mhs)
Added pixel formats Y16 and SBGGR16, new controls and a camera controls class. Removed VIDIOC_G/S_MPEGCOMP.
revision: 0.23 / 2007-08-30 (mhs)
Fixed a typo in VIDIOC_DBG_G/S_REGISTER. Clarified the byte order of packed pixel formats.
revision: 0.22 / 2007-08-29 (mhs)
Added the Video Output Overlay interface, new MPEG controls, V4L2_FIELD_INTERLACED_TB and V4L2_FIELD_INTERLACED_BT, VIDIOC_DBG_G/S_REGISTER, VIDIOC_(TRY_)ENCODER_CMD, VIDIOC_G_CHIP_IDENT, VIDIOC_G_ENC_INDEX, new pixel formats. Clarifications in the cropping chapter, about RGB pixel formats, the mmap(), poll(), select(), read() and write() functions. Typographical fixes.
revision: 0.21 / 2006-12-19 (mhs)
Fixed a link in the VIDIOC_G_EXT_CTRLS section.
revision: 0.20 / 2006-11-24 (mhs)
Clarified the purpose of the audioset field in struct v4l2_input and v4l2_output.
revision: 0.19 / 2006-10-19 (mhs)
Documented V4L2_PIX_FMT_RGB444.
revision: 0.18 / 2006-10-18 (mhs)
Added the description of extended controls by Hans Verkuil. Linked V4L2_PIX_FMT_MPEG to V4L2_CID_MPEG_STREAM_TYPE.
revision: 0.17 / 2006-10-12 (mhs)
Corrected V4L2_PIX_FMT_HM12 description.
revision: 0.16 / 2006-10-08 (mhs)
VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS are now part of the API.
revision: 0.15 / 2006-09-23 (mhs)
Cleaned up the bibliography, added BT.653 and BT.1119. capture.c/start_capturing() for user pointer I/O did not initialize the buffer index. Documented the V4L MPEG and MJPEG VID_TYPEs and V4L2_PIX_FMT_SBGGR8. Updated the list of reserved pixel formats. See the history chapter for API changes.
revision: 0.14 / 2006-09-14 (mr)
Added VIDIOC_ENUM_FRAMESIZES and VIDIOC_ENUM_FRAMEINTERVALS proposal for frame format enumeration of digital devices.
revision: 0.13 / 2006-04-07 (mhs)
Corrected the description of struct v4l2_window clips. New V4L2_STD_ and V4L2_TUNER_MODE_LANG1_LANG2 defines.
revision: 0.12 / 2006-02-03 (mhs)
Corrected the description of struct v4l2_captureparm and v4l2_outputparm.
revision: 0.11 / 2006-01-27 (mhs)
Improved the description of struct v4l2_tuner.
revision: 0.10 / 2006-01-10 (mhs)
VIDIOC_G_INPUT and VIDIOC_S_PARM clarifications.
revision: 0.9 / 2005-11-27 (mhs)
Improved the 525 line numbering diagram. Hans Verkuil and I rewrote the sliced VBI section. He also contributed a VIDIOC_LOG_STATUS page. Fixed VIDIOC_S_STD call in the video standard selection example. Various updates.
revision: 0.8 / 2004-10-04 (mhs)
Somehow a piece of junk slipped into the capture example, removed.
revision: 0.7 / 2004-09-19 (mhs)
Fixed video standard selection, control enumeration, downscaling and aspect example. Added read and user pointer i/o to video capture example.
revision: 0.6 / 2004-08-01 (mhs)
v4l2_buffer changes, added video capture example, various corrections.
revision: 0.5 / 2003-11-05 (mhs)
Pixel format erratum.
revision: 0.4 / 2003-09-17 (mhs)
Corrected source and Makefile to generate a PDF. SGML fixes. Added latest API changes. Closed gaps in the history chapter.
revision: 0.3 / 2003-02-05 (mhs)
Another draft, more corrections.
revision: 0.2 / 2003-01-15 (mhs)
Second draft, with corrections pointed out by Gerd Knorr.
revision: 0.1 / 2002-12-01 (mhs)
First draft, based on documentation by Bill Dirks and discussions on the V4L mailing list.
Video Grabber example using libv4l
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
This program demonstrates how to grab V4L2 images in ppm format by using libv4l handlers. The advantage is that this grabber can potentially work with any V4L2 driver.
file: media/v4l/v4l2grab.c
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
/* V4L2 video picture grabber
Copyright (C) 2009 Mauro Carvalho Chehab <mchehab@kernel.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
;
static void
int
Video Inputs and Outputs
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Video inputs and outputs are physical connectors of a device. These can be for example: RF connectors (antenna/cable), CVBS a.k.a. Composite Video, S-Video and RGB connectors. Camera sensors are also considered to be a video input. Video and VBI capture devices have inputs. Video and VBI output devices have outputs, at least one each. Radio devices have no video inputs or outputs.
To learn about the number and attributes of the available inputs and outputs applications can enumerate them with the ioctl VIDIOC_ENUMINPUT and ioctl VIDIOC_ENUMOUTPUT ioctl, respectively. The struct v4l2_input returned by the ioctl VIDIOC_ENUMINPUT ioctl also contains signal status information applicable when the current video input is queried.
The VIDIOC_G_INPUT and VIDIOC_G_OUTPUT ioctls return the index of the current video input or output. To select a different input or output applications call the VIDIOC_S_INPUT and VIDIOC_S_OUTPUT ioctls. Drivers must implement all the input ioctls when the device has one or more inputs, all the output ioctls when the device has one or more outputs.
Example: Information about the current video input #
struct v4l2_input input;
int index;
if
;
input.index = index;
if
;
Example: Switching to the first video input #
int index;
index = 0;
if
Video For Linux Two Header uAPI Symbols
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Enumeration values #
V4L2_BUF_TYPE_META_CAPTURE:include/uapi/linux/videodev2.h, line 154V4L2_BUF_TYPE_META_OUTPUT:include/uapi/linux/videodev2.h, line 155V4L2_BUF_TYPE_SDR_CAPTURE:include/uapi/linux/videodev2.h, line 152V4L2_BUF_TYPE_SDR_OUTPUT:include/uapi/linux/videodev2.h, line 153V4L2_BUF_TYPE_SLICED_VBI_CAPTURE:include/uapi/linux/videodev2.h, line 147V4L2_BUF_TYPE_SLICED_VBI_OUTPUT:include/uapi/linux/videodev2.h, line 148V4L2_BUF_TYPE_VBI_CAPTURE:include/uapi/linux/videodev2.h, line 145V4L2_BUF_TYPE_VBI_OUTPUT:include/uapi/linux/videodev2.h, line 146V4L2_BUF_TYPE_VIDEO_CAPTURE:include/uapi/linux/videodev2.h, line 142V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE:include/uapi/linux/videodev2.h, line 150V4L2_BUF_TYPE_VIDEO_OUTPUT:include/uapi/linux/videodev2.h, line 143V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE:include/uapi/linux/videodev2.h, line 151V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY:include/uapi/linux/videodev2.h, line 149V4L2_BUF_TYPE_VIDEO_OVERLAY:include/uapi/linux/videodev2.h, line 144V4L2_COLORSPACE_470_SYSTEM_BG:include/uapi/linux/videodev2.h, line 234V4L2_COLORSPACE_470_SYSTEM_M:include/uapi/linux/videodev2.h, line 229V4L2_COLORSPACE_BT2020:include/uapi/linux/videodev2.h, line 249V4L2_COLORSPACE_DCI_P3:include/uapi/linux/videodev2.h, line 255V4L2_COLORSPACE_DEFAULT:include/uapi/linux/videodev2.h, line 208V4L2_COLORSPACE_JPEG:include/uapi/linux/videodev2.h, line 240V4L2_COLORSPACE_LAST:include/uapi/linux/videodev2.h, line 262V4L2_COLORSPACE_OPRGB:include/uapi/linux/videodev2.h, line 246V4L2_COLORSPACE_RAW:include/uapi/linux/videodev2.h, line 252V4L2_COLORSPACE_REC709:include/uapi/linux/videodev2.h, line 217V4L2_COLORSPACE_SMPTE170M:include/uapi/linux/videodev2.h, line 211V4L2_COLORSPACE_SMPTE240M:include/uapi/linux/videodev2.h, line 214V4L2_COLORSPACE_SRGB:include/uapi/linux/videodev2.h, line 243V4L2_CTRL_COMPOUND_TYPES:include/uapi/linux/videodev2.h, line 1956V4L2_CTRL_TYPE_AREA:include/uapi/linux/videodev2.h, line 1960V4L2_CTRL_TYPE_AV1_FILM_GRAIN:include/uapi/linux/videodev2.h, line 1995V4L2_CTRL_TYPE_AV1_FRAME:include/uapi/linux/videodev2.h, line 1994V4L2_CTRL_TYPE_AV1_SEQUENCE:include/uapi/linux/videodev2.h, line 1992V4L2_CTRL_TYPE_AV1_TILE_GROUP_ENTRY:include/uapi/linux/videodev2.h, line 1993V4L2_CTRL_TYPE_BITMASK:include/uapi/linux/videodev2.h, line 1952V4L2_CTRL_TYPE_BOOLEAN:include/uapi/linux/videodev2.h, line 1946V4L2_CTRL_TYPE_BUTTON:include/uapi/linux/videodev2.h, line 1948V4L2_CTRL_TYPE_CTRL_CLASS:include/uapi/linux/videodev2.h, line 1950V4L2_CTRL_TYPE_FWHT_PARAMS:include/uapi/linux/videodev2.h, line 1973V4L2_CTRL_TYPE_H264_DECODE_PARAMS:include/uapi/linux/videodev2.h, line 1970V4L2_CTRL_TYPE_H264_PPS:include/uapi/linux/videodev2.h, line 1967V4L2_CTRL_TYPE_H264_PRED_WEIGHTS:include/uapi/linux/videodev2.h, line 1971V4L2_CTRL_TYPE_H264_SCALING_MATRIX:include/uapi/linux/videodev2.h, line 1968V4L2_CTRL_TYPE_H264_SLICE_PARAMS:include/uapi/linux/videodev2.h, line 1969V4L2_CTRL_TYPE_H264_SPS:include/uapi/linux/videodev2.h, line 1966V4L2_CTRL_TYPE_HDR10_CLL_INFO:include/uapi/linux/videodev2.h, line 1963V4L2_CTRL_TYPE_HDR10_MASTERING_DISPLAY:include/uapi/linux/videodev2.h, line 1964V4L2_CTRL_TYPE_HEVC_DECODE_PARAMS:include/uapi/linux/videodev2.h, line 1988V4L2_CTRL_TYPE_HEVC_EXT_SPS_LT_RPS:include/uapi/linux/videodev2.h, line 1990V4L2_CTRL_TYPE_HEVC_EXT_SPS_ST_RPS:include/uapi/linux/videodev2.h, line 1989V4L2_CTRL_TYPE_HEVC_PPS:include/uapi/linux/videodev2.h, line 1985V4L2_CTRL_TYPE_HEVC_SCALING_MATRIX:include/uapi/linux/videodev2.h, line 1987V4L2_CTRL_TYPE_HEVC_SLICE_PARAMS:include/uapi/linux/videodev2.h, line 1986V4L2_CTRL_TYPE_HEVC_SPS:include/uapi/linux/videodev2.h, line 1984V4L2_CTRL_TYPE_INTEGER:include/uapi/linux/videodev2.h, line 1945V4L2_CTRL_TYPE_INTEGER64:include/uapi/linux/videodev2.h, line 1949V4L2_CTRL_TYPE_INTEGER_MENU:include/uapi/linux/videodev2.h, line 1953V4L2_CTRL_TYPE_MENU:include/uapi/linux/videodev2.h, line 1947V4L2_CTRL_TYPE_MPEG2_PICTURE:include/uapi/linux/videodev2.h, line 1979V4L2_CTRL_TYPE_MPEG2_QUANTISATION:include/uapi/linux/videodev2.h, line 1977V4L2_CTRL_TYPE_MPEG2_SEQUENCE:include/uapi/linux/videodev2.h, line 1978V4L2_CTRL_TYPE_RECT:include/uapi/linux/videodev2.h, line 1961V4L2_CTRL_TYPE_STRING:include/uapi/linux/videodev2.h, line 1951V4L2_CTRL_TYPE_U16:include/uapi/linux/videodev2.h, line 1958V4L2_CTRL_TYPE_U32:include/uapi/linux/videodev2.h, line 1959V4L2_CTRL_TYPE_U8:include/uapi/linux/videodev2.h, line 1957V4L2_CTRL_TYPE_VP8_FRAME:include/uapi/linux/videodev2.h, line 1975V4L2_CTRL_TYPE_VP9_COMPRESSED_HDR:include/uapi/linux/videodev2.h, line 1981V4L2_CTRL_TYPE_VP9_FRAME:include/uapi/linux/videodev2.h, line 1982V4L2_FIELD_ALTERNATE:include/uapi/linux/videodev2.h, line 101V4L2_FIELD_ANY:include/uapi/linux/videodev2.h, line 92V4L2_FIELD_BOTTOM:include/uapi/linux/videodev2.h, line 95V4L2_FIELD_INTERLACED:include/uapi/linux/videodev2.h, line 96V4L2_FIELD_INTERLACED_BT:include/uapi/linux/videodev2.h, line 107V4L2_FIELD_INTERLACED_TB:include/uapi/linux/videodev2.h, line 104V4L2_FIELD_NONE:include/uapi/linux/videodev2.h, line 93V4L2_FIELD_SEQ_BT:include/uapi/linux/videodev2.h, line 99V4L2_FIELD_SEQ_TB:include/uapi/linux/videodev2.h, line 98V4L2_FIELD_TOP:include/uapi/linux/videodev2.h, line 94V4L2_FRMIVAL_TYPE_CONTINUOUS:include/uapi/linux/videodev2.h, line 983V4L2_FRMIVAL_TYPE_DISCRETE:include/uapi/linux/videodev2.h, line 982V4L2_FRMIVAL_TYPE_STEPWISE:include/uapi/linux/videodev2.h, line 984V4L2_FRMSIZE_TYPE_CONTINUOUS:include/uapi/linux/videodev2.h, line 947V4L2_FRMSIZE_TYPE_DISCRETE:include/uapi/linux/videodev2.h, line 946V4L2_FRMSIZE_TYPE_STEPWISE:include/uapi/linux/videodev2.h, line 948V4L2_HSV_ENC_180:include/uapi/linux/videodev2.h, line 385V4L2_HSV_ENC_256:include/uapi/linux/videodev2.h, line 388V4L2_MEMORY_DMABUF:include/uapi/linux/videodev2.h, line 199V4L2_MEMORY_MMAP:include/uapi/linux/videodev2.h, line 196V4L2_MEMORY_OVERLAY:include/uapi/linux/videodev2.h, line 198V4L2_MEMORY_USERPTR:include/uapi/linux/videodev2.h, line 197V4L2_PRIORITY_BACKGROUND:include/uapi/linux/videodev2.h, line 436V4L2_PRIORITY_DEFAULT:include/uapi/linux/videodev2.h, line 439V4L2_PRIORITY_INTERACTIVE:include/uapi/linux/videodev2.h, line 437V4L2_PRIORITY_RECORD:include/uapi/linux/videodev2.h, line 438V4L2_PRIORITY_UNSET:include/uapi/linux/videodev2.h, line 435V4L2_QUANTIZATION_DEFAULT:include/uapi/linux/videodev2.h, line 408V4L2_QUANTIZATION_FULL_RANGE:include/uapi/linux/videodev2.h, line 409V4L2_QUANTIZATION_LIM_RANGE:include/uapi/linux/videodev2.h, line 410V4L2_TUNER_ANALOG_TV:include/uapi/linux/videodev2.h, line 186V4L2_TUNER_RADIO:include/uapi/linux/videodev2.h, line 185V4L2_TUNER_RF:include/uapi/linux/videodev2.h, line 189V4L2_TUNER_SDR:include/uapi/linux/videodev2.h, line 188V4L2_XFER_FUNC_709:include/uapi/linux/videodev2.h, line 295V4L2_XFER_FUNC_DCI_P3:include/uapi/linux/videodev2.h, line 300V4L2_XFER_FUNC_DEFAULT:include/uapi/linux/videodev2.h, line 294V4L2_XFER_FUNC_LAST:include/uapi/linux/videodev2.h, line 307V4L2_XFER_FUNC_NONE:include/uapi/linux/videodev2.h, line 299V4L2_XFER_FUNC_OPRGB:include/uapi/linux/videodev2.h, line 297V4L2_XFER_FUNC_SMPTE2084:include/uapi/linux/videodev2.h, line 301V4L2_XFER_FUNC_SMPTE240M:include/uapi/linux/videodev2.h, line 298V4L2_XFER_FUNC_SRGB:include/uapi/linux/videodev2.h, line 296V4L2_YCBCR_ENC_601:include/uapi/linux/videodev2.h, line 341V4L2_YCBCR_ENC_709:include/uapi/linux/videodev2.h, line 344V4L2_YCBCR_ENC_BT2020:include/uapi/linux/videodev2.h, line 362V4L2_YCBCR_ENC_BT2020_CONST_LUM:include/uapi/linux/videodev2.h, line 365V4L2_YCBCR_ENC_DEFAULT:include/uapi/linux/videodev2.h, line 338V4L2_YCBCR_ENC_LAST:include/uapi/linux/videodev2.h, line 374V4L2_YCBCR_ENC_SMPTE240M:include/uapi/linux/videodev2.h, line 368V4L2_YCBCR_ENC_SYCC:include/uapi/linux/videodev2.h, line 358V4L2_YCBCR_ENC_XV601:include/uapi/linux/videodev2.h, line 347V4L2_YCBCR_ENC_XV709:include/uapi/linux/videodev2.h, line 350
Enumerations #
v4l2_buf_type:include/uapi/linux/videodev2.h, line 141v4l2_colorspace:include/uapi/linux/videodev2.h, line 203v4l2_ctrl_type:include/uapi/linux/videodev2.h, line 1944v4l2_field:include/uapi/linux/videodev2.h, line 88v4l2_frmivaltypes:include/uapi/linux/videodev2.h, line 981v4l2_frmsizetypes:include/uapi/linux/videodev2.h, line 945v4l2_hsv_encoding:include/uapi/linux/videodev2.h, line 382v4l2_memory:include/uapi/linux/videodev2.h, line 195v4l2_priority:include/uapi/linux/videodev2.h, line 434v4l2_quantization:include/uapi/linux/videodev2.h, line 402v4l2_tuner_type:include/uapi/linux/videodev2.h, line 184v4l2_xfer_func:include/uapi/linux/videodev2.h, line 275v4l2_ycbcr_encoding:include/uapi/linux/videodev2.h, line 323
IOCTL Commands #
VIDIOC_CREATE_BUFS:include/uapi/linux/videodev2.h, line 2807VIDIOC_CROPCAP:include/uapi/linux/videodev2.h, line 2771VIDIOC_DBG_G_CHIP_INFO:include/uapi/linux/videodev2.h, line 2822VIDIOC_DBG_G_REGISTER:include/uapi/linux/videodev2.h, line 2799VIDIOC_DBG_S_REGISTER:include/uapi/linux/videodev2.h, line 2798VIDIOC_DECODER_CMD:include/uapi/linux/videodev2.h, line 2811VIDIOC_DQBUF:include/uapi/linux/videodev2.h, line 2741VIDIOC_DQEVENT:include/uapi/linux/videodev2.h, line 2804VIDIOC_DV_TIMINGS_CAP:include/uapi/linux/videodev2.h, line 2815VIDIOC_ENCODER_CMD:include/uapi/linux/videodev2.h, line 2790VIDIOC_ENUMAUDIO:include/uapi/linux/videodev2.h, line 2778VIDIOC_ENUMAUDOUT:include/uapi/linux/videodev2.h, line 2779VIDIOC_ENUMINPUT:include/uapi/linux/videodev2.h, line 2749VIDIOC_ENUMOUTPUT:include/uapi/linux/videodev2.h, line 2764VIDIOC_ENUMSTD:include/uapi/linux/videodev2.h, line 2748VIDIOC_ENUM_DV_TIMINGS:include/uapi/linux/videodev2.h, line 2813VIDIOC_ENUM_FMT:include/uapi/linux/videodev2.h, line 2731VIDIOC_ENUM_FRAMEINTERVALS:include/uapi/linux/videodev2.h, line 2788VIDIOC_ENUM_FRAMESIZES:include/uapi/linux/videodev2.h, line 2787VIDIOC_ENUM_FREQ_BANDS:include/uapi/linux/videodev2.h, line 2816VIDIOC_EXPBUF:include/uapi/linux/videodev2.h, line 2740VIDIOC_G_AUDIO:include/uapi/linux/videodev2.h, line 2754VIDIOC_G_AUDOUT:include/uapi/linux/videodev2.h, line 2765VIDIOC_G_CROP:include/uapi/linux/videodev2.h, line 2772VIDIOC_G_CTRL:include/uapi/linux/videodev2.h, line 2750VIDIOC_G_DV_TIMINGS:include/uapi/linux/videodev2.h, line 2803VIDIOC_G_EDID:include/uapi/linux/videodev2.h, line 2760VIDIOC_G_ENC_INDEX:include/uapi/linux/videodev2.h, line 2789VIDIOC_G_EXT_CTRLS:include/uapi/linux/videodev2.h, line 2784VIDIOC_G_FBUF:include/uapi/linux/videodev2.h, line 2736VIDIOC_G_FMT:include/uapi/linux/videodev2.h, line 2732VIDIOC_G_FREQUENCY:include/uapi/linux/videodev2.h, line 2769VIDIOC_G_INPUT:include/uapi/linux/videodev2.h, line 2758VIDIOC_G_JPEGCOMP:include/uapi/linux/videodev2.h, line 2774VIDIOC_G_MODULATOR:include/uapi/linux/videodev2.h, line 2767VIDIOC_G_OUTPUT:include/uapi/linux/videodev2.h, line 2762VIDIOC_G_PARM:include/uapi/linux/videodev2.h, line 2744VIDIOC_G_PRIORITY:include/uapi/linux/videodev2.h, line 2780VIDIOC_G_SELECTION:include/uapi/linux/videodev2.h, line 2809VIDIOC_G_SLICED_VBI_CAP:include/uapi/linux/videodev2.h, line 2782VIDIOC_G_STD:include/uapi/linux/videodev2.h, line 2746VIDIOC_G_TUNER:include/uapi/linux/videodev2.h, line 2752VIDIOC_LOG_STATUS:include/uapi/linux/videodev2.h, line 2783VIDIOC_OVERLAY:include/uapi/linux/videodev2.h, line 2738VIDIOC_PREPARE_BUF:include/uapi/linux/videodev2.h, line 2808VIDIOC_QBUF:include/uapi/linux/videodev2.h, line 2739VIDIOC_QUERYBUF:include/uapi/linux/videodev2.h, line 2735VIDIOC_QUERYCAP:include/uapi/linux/videodev2.h, line 2730VIDIOC_QUERYCTRL:include/uapi/linux/videodev2.h, line 2756VIDIOC_QUERYMENU:include/uapi/linux/videodev2.h, line 2757VIDIOC_QUERYSTD:include/uapi/linux/videodev2.h, line 2776VIDIOC_QUERY_DV_TIMINGS:include/uapi/linux/videodev2.h, line 2814VIDIOC_QUERY_EXT_CTRL:include/uapi/linux/videodev2.h, line 2824VIDIOC_REMOVE_BUFS:include/uapi/linux/videodev2.h, line 2825VIDIOC_REQBUFS:include/uapi/linux/videodev2.h, line 2734VIDIOC_STREAMOFF:include/uapi/linux/videodev2.h, line 2743VIDIOC_STREAMON:include/uapi/linux/videodev2.h, line 2742VIDIOC_SUBSCRIBE_EVENT:include/uapi/linux/videodev2.h, line 2805VIDIOC_S_AUDIO:include/uapi/linux/videodev2.h, line 2755VIDIOC_S_AUDOUT:include/uapi/linux/videodev2.h, line 2766VIDIOC_S_CROP:include/uapi/linux/videodev2.h, line 2773VIDIOC_S_CTRL:include/uapi/linux/videodev2.h, line 2751VIDIOC_S_DV_TIMINGS:include/uapi/linux/videodev2.h, line 2802VIDIOC_S_EDID:include/uapi/linux/videodev2.h, line 2761VIDIOC_S_EXT_CTRLS:include/uapi/linux/videodev2.h, line 2785VIDIOC_S_FBUF:include/uapi/linux/videodev2.h, line 2737VIDIOC_S_FMT:include/uapi/linux/videodev2.h, line 2733VIDIOC_S_FREQUENCY:include/uapi/linux/videodev2.h, line 2770VIDIOC_S_HW_FREQ_SEEK:include/uapi/linux/videodev2.h, line 2801VIDIOC_S_INPUT:include/uapi/linux/videodev2.h, line 2759VIDIOC_S_JPEGCOMP:include/uapi/linux/videodev2.h, line 2775VIDIOC_S_MODULATOR:include/uapi/linux/videodev2.h, line 2768VIDIOC_S_OUTPUT:include/uapi/linux/videodev2.h, line 2763VIDIOC_S_PARM:include/uapi/linux/videodev2.h, line 2745VIDIOC_S_PRIORITY:include/uapi/linux/videodev2.h, line 2781VIDIOC_S_SELECTION:include/uapi/linux/videodev2.h, line 2810VIDIOC_S_STD:include/uapi/linux/videodev2.h, line 2747VIDIOC_S_TUNER:include/uapi/linux/videodev2.h, line 2753VIDIOC_TRY_DECODER_CMD:include/uapi/linux/videodev2.h, line 2812VIDIOC_TRY_ENCODER_CMD:include/uapi/linux/videodev2.h, line 2791VIDIOC_TRY_EXT_CTRLS:include/uapi/linux/videodev2.h, line 2786VIDIOC_TRY_FMT:include/uapi/linux/videodev2.h, line 2777VIDIOC_UNSUBSCRIBE_EVENT:include/uapi/linux/videodev2.h, line 2806
Macros and Definitions #
V4L2_AUDCAP_AVL:include/uapi/linux/videodev2.h, line 2191V4L2_AUDCAP_STEREO:include/uapi/linux/videodev2.h, line 2190V4L2_AUDMODE_AVL:include/uapi/linux/videodev2.h, line 2194V4L2_BAND_MODULATION_AM:include/uapi/linux/videodev2.h, line 2133V4L2_BAND_MODULATION_FM:include/uapi/linux/videodev2.h, line 2132V4L2_BAND_MODULATION_VSB:include/uapi/linux/videodev2.h, line 2131V4L2_BUF_CAP_SUPPORTS_DMABUF:include/uapi/linux/videodev2.h, line 1101V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF:include/uapi/linux/videodev2.h, line 1104V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS:include/uapi/linux/videodev2.h, line 1106V4L2_BUF_CAP_SUPPORTS_MMAP:include/uapi/linux/videodev2.h, line 1099V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS:include/uapi/linux/videodev2.h, line 1105V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS:include/uapi/linux/videodev2.h, line 1103V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS:include/uapi/linux/videodev2.h, line 1107V4L2_BUF_CAP_SUPPORTS_REQUESTS:include/uapi/linux/videodev2.h, line 1102V4L2_BUF_CAP_SUPPORTS_USERPTR:include/uapi/linux/videodev2.h, line 1100V4L2_BUF_FLAG_BFRAME:include/uapi/linux/videodev2.h, line 1234V4L2_BUF_FLAG_DONE:include/uapi/linux/videodev2.h, line 1228V4L2_BUF_FLAG_ERROR:include/uapi/linux/videodev2.h, line 1236V4L2_BUF_FLAG_IN_REQUEST:include/uapi/linux/videodev2.h, line 1238V4L2_BUF_FLAG_KEYFRAME:include/uapi/linux/videodev2.h, line 1230V4L2_BUF_FLAG_LAST:include/uapi/linux/videodev2.h, line 1258V4L2_BUF_FLAG_M2M_HOLD_CAPTURE_BUF:include/uapi/linux/videodev2.h, line 1242V4L2_BUF_FLAG_MAPPED:include/uapi/linux/videodev2.h, line 1224V4L2_BUF_FLAG_NO_CACHE_CLEAN:include/uapi/linux/videodev2.h, line 1247V4L2_BUF_FLAG_NO_CACHE_INVALIDATE:include/uapi/linux/videodev2.h, line 1246V4L2_BUF_FLAG_PFRAME:include/uapi/linux/videodev2.h, line 1232V4L2_BUF_FLAG_PREPARED:include/uapi/linux/videodev2.h, line 1244V4L2_BUF_FLAG_QUEUED:include/uapi/linux/videodev2.h, line 1226V4L2_BUF_FLAG_REQUEST_FD:include/uapi/linux/videodev2.h, line 1260V4L2_BUF_FLAG_TIMECODE:include/uapi/linux/videodev2.h, line 1240V4L2_BUF_FLAG_TIMESTAMP_COPY:include/uapi/linux/videodev2.h, line 1252V4L2_BUF_FLAG_TIMESTAMP_MASK:include/uapi/linux/videodev2.h, line 1249V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC:include/uapi/linux/videodev2.h, line 1251V4L2_BUF_FLAG_TIMESTAMP_UNKNOWN:include/uapi/linux/videodev2.h, line 1250V4L2_BUF_FLAG_TSTAMP_SRC_EOF:include/uapi/linux/videodev2.h, line 1255V4L2_BUF_FLAG_TSTAMP_SRC_MASK:include/uapi/linux/videodev2.h, line 1254V4L2_BUF_FLAG_TSTAMP_SRC_SOE:include/uapi/linux/videodev2.h, line 1256V4L2_CAP_ASYNCIO:include/uapi/linux/videodev2.h, line 2841V4L2_CAP_AUDIO:include/uapi/linux/videodev2.h, line 503V4L2_CAP_DEVICE_CAPS:include/uapi/linux/videodev2.h, line 521V4L2_CAP_EDID:include/uapi/linux/videodev2.h, line 513V4L2_CAP_EXT_PIX_FORMAT:include/uapi/linux/videodev2.h, line 508V4L2_CAP_HW_FREQ_SEEK:include/uapi/linux/videodev2.h, line 490V4L2_CAP_IO_MC:include/uapi/linux/videodev2.h, line 519V4L2_CAP_META_CAPTURE:include/uapi/linux/videodev2.h, line 510V4L2_CAP_META_OUTPUT:include/uapi/linux/videodev2.h, line 515V4L2_CAP_MODULATOR:include/uapi/linux/videodev2.h, line 505V4L2_CAP_RADIO:include/uapi/linux/videodev2.h, line 504V4L2_CAP_RDS_CAPTURE:include/uapi/linux/videodev2.h, line 488V4L2_CAP_RDS_OUTPUT:include/uapi/linux/videodev2.h, line 491V4L2_CAP_READWRITE:include/uapi/linux/videodev2.h, line 512V4L2_CAP_SDR_CAPTURE:include/uapi/linux/videodev2.h, line 507V4L2_CAP_SDR_OUTPUT:include/uapi/linux/videodev2.h, line 509V4L2_CAP_SLICED_VBI_CAPTURE:include/uapi/linux/videodev2.h, line 486V4L2_CAP_SLICED_VBI_OUTPUT:include/uapi/linux/videodev2.h, line 487V4L2_CAP_STREAMING:include/uapi/linux/videodev2.h, line 514V4L2_CAP_TIMEPERFRAME:include/uapi/linux/videodev2.h, line 1359V4L2_CAP_TOUCH:include/uapi/linux/videodev2.h, line 517V4L2_CAP_TUNER:include/uapi/linux/videodev2.h, line 502V4L2_CAP_VBI_CAPTURE:include/uapi/linux/videodev2.h, line 484V4L2_CAP_VBI_OUTPUT:include/uapi/linux/videodev2.h, line 485V4L2_CAP_VIDEO_CAPTURE:include/uapi/linux/videodev2.h, line 481V4L2_CAP_VIDEO_CAPTURE_MPLANE:include/uapi/linux/videodev2.h, line 494V4L2_CAP_VIDEO_M2M:include/uapi/linux/videodev2.h, line 500V4L2_CAP_VIDEO_M2M_MPLANE:include/uapi/linux/videodev2.h, line 498V4L2_CAP_VIDEO_OUTPUT:include/uapi/linux/videodev2.h, line 482V4L2_CAP_VIDEO_OUTPUT_MPLANE:include/uapi/linux/videodev2.h, line 496V4L2_CAP_VIDEO_OUTPUT_OVERLAY:include/uapi/linux/videodev2.h, line 489V4L2_CAP_VIDEO_OVERLAY:include/uapi/linux/videodev2.h, line 483V4L2_CHIP_FL_READABLE:include/uapi/linux/videodev2.h, line 2674V4L2_CHIP_FL_WRITABLE:include/uapi/linux/videodev2.h, line 2675V4L2_CHIP_MATCH_AC97:include/uapi/linux/videodev2.h, line 2657V4L2_CHIP_MATCH_BRIDGE:include/uapi/linux/videodev2.h, line 2650V4L2_CHIP_MATCH_HOST:include/uapi/linux/videodev2.h, line 2654V4L2_CHIP_MATCH_I2C_ADDR:include/uapi/linux/videodev2.h, line 2656V4L2_CHIP_MATCH_I2C_DRIVER:include/uapi/linux/videodev2.h, line 2655V4L2_CHIP_MATCH_SUBDEV:include/uapi/linux/videodev2.h, line 2651V4L2_CID_PRIVATE_BASE:include/uapi/linux/videodev2.h, line 2061V4L2_COLORSPACE_ADOBERGB:include/uapi/linux/videodev2.h, line 430V4L2_CTRL_FLAG_DISABLED:include/uapi/linux/videodev2.h, line 2040V4L2_CTRL_FLAG_DYNAMIC_ARRAY:include/uapi/linux/videodev2.h, line 2051V4L2_CTRL_FLAG_EXECUTE_ON_WRITE:include/uapi/linux/videodev2.h, line 2049V4L2_CTRL_FLAG_GRABBED:include/uapi/linux/videodev2.h, line 2041V4L2_CTRL_FLAG_HAS_PAYLOAD:include/uapi/linux/videodev2.h, line 2048V4L2_CTRL_FLAG_HAS_WHICH_MIN_MAX:include/uapi/linux/videodev2.h, line 2052V4L2_CTRL_FLAG_INACTIVE:include/uapi/linux/videodev2.h, line 2044V4L2_CTRL_FLAG_MODIFY_LAYOUT:include/uapi/linux/videodev2.h, line 2050V4L2_CTRL_FLAG_NEXT_COMPOUND:include/uapi/linux/videodev2.h, line 2056V4L2_CTRL_FLAG_NEXT_CTRL:include/uapi/linux/videodev2.h, line 2055V4L2_CTRL_FLAG_READ_ONLY:include/uapi/linux/videodev2.h, line 2042V4L2_CTRL_FLAG_SLIDER:include/uapi/linux/videodev2.h, line 2045V4L2_CTRL_FLAG_UPDATE:include/uapi/linux/videodev2.h, line 2043V4L2_CTRL_FLAG_VOLATILE:include/uapi/linux/videodev2.h, line 2047V4L2_CTRL_FLAG_WRITE_ONLY:include/uapi/linux/videodev2.h, line 2046V4L2_DEC_CMD_FLUSH:include/uapi/linux/videodev2.h, line 2253V4L2_DEC_CMD_PAUSE:include/uapi/linux/videodev2.h, line 2251V4L2_DEC_CMD_PAUSE_TO_BLACK:include/uapi/linux/videodev2.h, line 2259V4L2_DEC_CMD_RESUME:include/uapi/linux/videodev2.h, line 2252V4L2_DEC_CMD_START:include/uapi/linux/videodev2.h, line 2249V4L2_DEC_CMD_START_MUTE_AUDIO:include/uapi/linux/videodev2.h, line 2256V4L2_DEC_CMD_STOP:include/uapi/linux/videodev2.h, line 2250V4L2_DEC_CMD_STOP_IMMEDIATELY:include/uapi/linux/videodev2.h, line 2263V4L2_DEC_CMD_STOP_TO_BLACK:include/uapi/linux/videodev2.h, line 2262V4L2_DEC_START_FMT_GOP:include/uapi/linux/videodev2.h, line 2270V4L2_DEC_START_FMT_NONE:include/uapi/linux/videodev2.h, line 2268V4L2_DV_BT_656_1120:include/uapi/linux/videodev2.h, line 1724V4L2_DV_BT_CAP_CUSTOM:include/uapi/linux/videodev2.h, line 1771V4L2_DV_BT_CAP_INTERLACED:include/uapi/linux/videodev2.h, line 1765V4L2_DV_BT_CAP_PROGRESSIVE:include/uapi/linux/videodev2.h, line 1767V4L2_DV_BT_CAP_REDUCED_BLANKING:include/uapi/linux/videodev2.h, line 1769V4L2_DV_BT_STD_CEA861:include/uapi/linux/videodev2.h, line 1623V4L2_DV_BT_STD_CVT:include/uapi/linux/videodev2.h, line 1625V4L2_DV_BT_STD_DMT:include/uapi/linux/videodev2.h, line 1624V4L2_DV_BT_STD_GTF:include/uapi/linux/videodev2.h, line 1626V4L2_DV_BT_STD_SDI:include/uapi/linux/videodev2.h, line 1627V4L2_DV_FL_CAN_DETECT_REDUCED_FPS:include/uapi/linux/videodev2.h, line 1697V4L2_DV_FL_CAN_REDUCE_FPS:include/uapi/linux/videodev2.h, line 1643V4L2_DV_FL_FIRST_FIELD_EXTRA_LINE:include/uapi/linux/videodev2.h, line 1673V4L2_DV_FL_HALF_LINE:include/uapi/linux/videodev2.h, line 1660V4L2_DV_FL_HAS_CEA861_VIC:include/uapi/linux/videodev2.h, line 1684V4L2_DV_FL_HAS_HDMI_VIC:include/uapi/linux/videodev2.h, line 1690V4L2_DV_FL_HAS_PICTURE_ASPECT:include/uapi/linux/videodev2.h, line 1679V4L2_DV_FL_IS_CE_VIDEO:include/uapi/linux/videodev2.h, line 1668V4L2_DV_FL_REDUCED_BLANKING:include/uapi/linux/videodev2.h, line 1637V4L2_DV_FL_REDUCED_FPS:include/uapi/linux/videodev2.h, line 1653V4L2_DV_HSYNC_POS_POL:include/uapi/linux/videodev2.h, line 1620V4L2_DV_INTERLACED:include/uapi/linux/videodev2.h, line 1616V4L2_DV_PROGRESSIVE:include/uapi/linux/videodev2.h, line 1615V4L2_DV_VSYNC_POS_POL:include/uapi/linux/videodev2.h, line 1619V4L2_ENC_CMD_PAUSE:include/uapi/linux/videodev2.h, line 2232V4L2_ENC_CMD_RESUME:include/uapi/linux/videodev2.h, line 2233V4L2_ENC_CMD_START:include/uapi/linux/videodev2.h, line 2230V4L2_ENC_CMD_STOP:include/uapi/linux/videodev2.h, line 2231V4L2_ENC_CMD_STOP_AT_GOP_END:include/uapi/linux/videodev2.h, line 2236V4L2_ENC_IDX_ENTRIES:include/uapi/linux/videodev2.h, line 2221V4L2_ENC_IDX_FRAME_B:include/uapi/linux/videodev2.h, line 2210V4L2_ENC_IDX_FRAME_I:include/uapi/linux/videodev2.h, line 2208V4L2_ENC_IDX_FRAME_MASK:include/uapi/linux/videodev2.h, line 2211V4L2_ENC_IDX_FRAME_P:include/uapi/linux/videodev2.h, line 2209V4L2_EVENT_ALL:include/uapi/linux/videodev2.h, line 2550V4L2_EVENT_CTRL:include/uapi/linux/videodev2.h, line 2553V4L2_EVENT_CTRL_CH_DIMENSIONS:include/uapi/linux/videodev2.h, line 2569V4L2_EVENT_CTRL_CH_FLAGS:include/uapi/linux/videodev2.h, line 2567V4L2_EVENT_CTRL_CH_RANGE:include/uapi/linux/videodev2.h, line 2568V4L2_EVENT_CTRL_CH_VALUE:include/uapi/linux/videodev2.h, line 2566V4L2_EVENT_EOS:include/uapi/linux/videodev2.h, line 2552V4L2_EVENT_FRAME_SYNC:include/uapi/linux/videodev2.h, line 2554V4L2_EVENT_MD_FL_HAVE_FRAME_SEQ:include/uapi/linux/videodev2.h, line 2595V4L2_EVENT_MOTION_DET:include/uapi/linux/videodev2.h, line 2556V4L2_EVENT_PRIVATE_START:include/uapi/linux/videodev2.h, line 2557V4L2_EVENT_SOURCE_CHANGE:include/uapi/linux/videodev2.h, line 2555V4L2_EVENT_SRC_CH_RESOLUTION:include/uapi/linux/videodev2.h, line 2589V4L2_EVENT_SUB_FL_ALLOW_FEEDBACK:include/uapi/linux/videodev2.h, line 2632V4L2_EVENT_SUB_FL_SEND_INITIAL:include/uapi/linux/videodev2.h, line 2631V4L2_EVENT_VSYNC:include/uapi/linux/videodev2.h, line 2551V4L2_FBUF_CAP_BITMAP_CLIPPING:include/uapi/linux/videodev2.h, line 1315V4L2_FBUF_CAP_CHROMAKEY:include/uapi/linux/videodev2.h, line 1312V4L2_FBUF_CAP_EXTERNOVERLAY:include/uapi/linux/videodev2.h, line 1311V4L2_FBUF_CAP_GLOBAL_ALPHA:include/uapi/linux/videodev2.h, line 1318V4L2_FBUF_CAP_LIST_CLIPPING:include/uapi/linux/videodev2.h, line 1314V4L2_FBUF_CAP_LOCAL_ALPHA:include/uapi/linux/videodev2.h, line 1317V4L2_FBUF_CAP_LOCAL_INV_ALPHA:include/uapi/linux/videodev2.h, line 1319V4L2_FBUF_CAP_SRC_CHROMAKEY:include/uapi/linux/videodev2.h, line 1320V4L2_FBUF_FLAG_CHROMAKEY:include/uapi/linux/videodev2.h, line 1324V4L2_FBUF_FLAG_GLOBAL_ALPHA:include/uapi/linux/videodev2.h, line 1326V4L2_FBUF_FLAG_LOCAL_ALPHA:include/uapi/linux/videodev2.h, line 1325V4L2_FBUF_FLAG_LOCAL_INV_ALPHA:include/uapi/linux/videodev2.h, line 1327V4L2_FBUF_FLAG_OVERLAY:include/uapi/linux/videodev2.h, line 1323V4L2_FBUF_FLAG_PRIMARY:include/uapi/linux/videodev2.h, line 1322V4L2_FBUF_FLAG_SRC_CHROMAKEY:include/uapi/linux/videodev2.h, line 1328V4L2_FMTDESC_FLAG_ENUM_ALL:include/uapi/linux/videodev2.h, line 939V4L2_FMT_FLAG_COMPRESSED:include/uapi/linux/videodev2.h, line 926V4L2_FMT_FLAG_CONTINUOUS_BYTESTREAM:include/uapi/linux/videodev2.h, line 928V4L2_FMT_FLAG_CSC_COLORSPACE:include/uapi/linux/videodev2.h, line 931V4L2_FMT_FLAG_CSC_HSV_ENC:include/uapi/linux/videodev2.h, line 934V4L2_FMT_FLAG_CSC_QUANTIZATION:include/uapi/linux/videodev2.h, line 935V4L2_FMT_FLAG_CSC_XFER_FUNC:include/uapi/linux/videodev2.h, line 932V4L2_FMT_FLAG_CSC_YCBCR_ENC:include/uapi/linux/videodev2.h, line 933V4L2_FMT_FLAG_DYN_RESOLUTION:include/uapi/linux/videodev2.h, line 929V4L2_FMT_FLAG_EMULATED:include/uapi/linux/videodev2.h, line 927V4L2_FMT_FLAG_ENC_CAP_FRAME_INTERVAL:include/uapi/linux/videodev2.h, line 930V4L2_FMT_FLAG_META_LINE_BASED:include/uapi/linux/videodev2.h, line 936V4L2_INPUT_TYPE_CAMERA:include/uapi/linux/videodev2.h, line 1807V4L2_INPUT_TYPE_TOUCH:include/uapi/linux/videodev2.h, line 1808V4L2_INPUT_TYPE_TUNER:include/uapi/linux/videodev2.h, line 1806V4L2_IN_CAP_DV_TIMINGS:include/uapi/linux/videodev2.h, line 1837V4L2_IN_CAP_NATIVE_SIZE:include/uapi/linux/videodev2.h, line 1840V4L2_IN_CAP_STD:include/uapi/linux/videodev2.h, line 1839V4L2_IN_ST_COLOR_KILL:include/uapi/linux/videodev2.h, line 1822V4L2_IN_ST_HFLIP:include/uapi/linux/videodev2.h, line 1817V4L2_IN_ST_MACROVISION:include/uapi/linux/videodev2.h, line 1832V4L2_IN_ST_NO_ACCESS:include/uapi/linux/videodev2.h, line 1833V4L2_IN_ST_NO_CARRIER:include/uapi/linux/videodev2.h, line 1829V4L2_IN_ST_NO_COLOR:include/uapi/linux/videodev2.h, line 1813V4L2_IN_ST_NO_EQU:include/uapi/linux/videodev2.h, line 1828V4L2_IN_ST_NO_H_LOCK:include/uapi/linux/videodev2.h, line 1821V4L2_IN_ST_NO_POWER:include/uapi/linux/videodev2.h, line 1811V4L2_IN_ST_NO_SIGNAL:include/uapi/linux/videodev2.h, line 1812V4L2_IN_ST_NO_STD_LOCK:include/uapi/linux/videodev2.h, line 1824V4L2_IN_ST_NO_SYNC:include/uapi/linux/videodev2.h, line 1827V4L2_IN_ST_NO_V_LOCK:include/uapi/linux/videodev2.h, line 1823V4L2_IN_ST_VFLIP:include/uapi/linux/videodev2.h, line 1818V4L2_IN_ST_VTR:include/uapi/linux/videodev2.h, line 1834V4L2_JPEG_MARKER_APP:include/uapi/linux/videodev2.h, line 1062V4L2_JPEG_MARKER_COM:include/uapi/linux/videodev2.h, line 1060V4L2_JPEG_MARKER_DHT:include/uapi/linux/videodev2.h, line 1057V4L2_JPEG_MARKER_DQT:include/uapi/linux/videodev2.h, line 1058V4L2_JPEG_MARKER_DRI:include/uapi/linux/videodev2.h, line 1059V4L2_MEMORY_FLAG_NON_COHERENT:include/uapi/linux/videodev2.h, line 1096V4L2_META_FMT_C3ISP_PARAMS:include/uapi/linux/videodev2.h, line 880V4L2_META_FMT_C3ISP_STATS:include/uapi/linux/videodev2.h, line 881V4L2_META_FMT_D4XX:include/uapi/linux/videodev2.h, line 870V4L2_META_FMT_GENERIC_8:include/uapi/linux/videodev2.h, line 897V4L2_META_FMT_GENERIC_CSI2_10:include/uapi/linux/videodev2.h, line 898V4L2_META_FMT_GENERIC_CSI2_12:include/uapi/linux/videodev2.h, line 899V4L2_META_FMT_GENERIC_CSI2_14:include/uapi/linux/videodev2.h, line 900V4L2_META_FMT_GENERIC_CSI2_16:include/uapi/linux/videodev2.h, line 901V4L2_META_FMT_GENERIC_CSI2_20:include/uapi/linux/videodev2.h, line 902V4L2_META_FMT_GENERIC_CSI2_24:include/uapi/linux/videodev2.h, line 903V4L2_META_FMT_MALI_C55_PARAMS:include/uapi/linux/videodev2.h, line 889V4L2_META_FMT_MALI_C55_STATS:include/uapi/linux/videodev2.h, line 890V4L2_META_FMT_RK_ISP1_EXT_PARAMS:include/uapi/linux/videodev2.h, line 877V4L2_META_FMT_RK_ISP1_PARAMS:include/uapi/linux/videodev2.h, line 875V4L2_META_FMT_RK_ISP1_STAT_3A:include/uapi/linux/videodev2.h, line 876V4L2_META_FMT_RPI_BE_CFG:include/uapi/linux/videodev2.h, line 884V4L2_META_FMT_RPI_FE_CFG:include/uapi/linux/videodev2.h, line 885V4L2_META_FMT_RPI_FE_STATS:include/uapi/linux/videodev2.h, line 886V4L2_META_FMT_UVC:include/uapi/linux/videodev2.h, line 869V4L2_META_FMT_UVC_MSXU_1_5:include/uapi/linux/videodev2.h, line 871V4L2_META_FMT_VIVID:include/uapi/linux/videodev2.h, line 872V4L2_META_FMT_VSP1_HGO:include/uapi/linux/videodev2.h, line 867V4L2_META_FMT_VSP1_HGT:include/uapi/linux/videodev2.h, line 868V4L2_MODE_HIGHQUALITY:include/uapi/linux/videodev2.h, line 1358V4L2_MPEG_VBI_IVTV_CAPTION_525:include/uapi/linux/videodev2.h, line 2396V4L2_MPEG_VBI_IVTV_MAGIC0:include/uapi/linux/videodev2.h, line 2414V4L2_MPEG_VBI_IVTV_MAGIC1:include/uapi/linux/videodev2.h, line 2415V4L2_MPEG_VBI_IVTV_TELETEXT_B:include/uapi/linux/videodev2.h, line 2395V4L2_MPEG_VBI_IVTV_VPS:include/uapi/linux/videodev2.h, line 2398V4L2_MPEG_VBI_IVTV_WSS_625:include/uapi/linux/videodev2.h, line 2397V4L2_OUTPUT_TYPE_ANALOG:include/uapi/linux/videodev2.h, line 1857V4L2_OUTPUT_TYPE_ANALOGVGAOVERLAY:include/uapi/linux/videodev2.h, line 1858V4L2_OUTPUT_TYPE_MODULATOR:include/uapi/linux/videodev2.h, line 1856V4L2_OUT_CAP_DV_TIMINGS:include/uapi/linux/videodev2.h, line 1861V4L2_OUT_CAP_NATIVE_SIZE:include/uapi/linux/videodev2.h, line 1864V4L2_OUT_CAP_STD:include/uapi/linux/videodev2.h, line 1863V4L2_PIX_FMT_ABGR32:include/uapi/linux/videodev2.h, line 579V4L2_PIX_FMT_ABGR444:include/uapi/linux/videodev2.h, line 555V4L2_PIX_FMT_ABGR555:include/uapi/linux/videodev2.h, line 564V4L2_PIX_FMT_ABGR64_12:include/uapi/linux/videodev2.h, line 596V4L2_PIX_FMT_AJPG:include/uapi/linux/videodev2.h, line 823V4L2_PIX_FMT_ARGB2101010:include/uapi/linux/videodev2.h, line 590V4L2_PIX_FMT_ARGB32:include/uapi/linux/videodev2.h, line 586V4L2_PIX_FMT_ARGB444:include/uapi/linux/videodev2.h, line 551V4L2_PIX_FMT_ARGB555:include/uapi/linux/videodev2.h, line 560V4L2_PIX_FMT_ARGB555X:include/uapi/linux/videodev2.h, line 570V4L2_PIX_FMT_AV1:include/uapi/linux/videodev2.h, line 778V4L2_PIX_FMT_AV1_FRAME:include/uapi/linux/videodev2.h, line 777V4L2_PIX_FMT_AYUV32:include/uapi/linux/videodev2.h, line 634V4L2_PIX_FMT_BGR24:include/uapi/linux/videodev2.h, line 576V4L2_PIX_FMT_BGR32:include/uapi/linux/videodev2.h, line 578V4L2_PIX_FMT_BGR48:include/uapi/linux/videodev2.h, line 594V4L2_PIX_FMT_BGR48_12:include/uapi/linux/videodev2.h, line 593V4L2_PIX_FMT_BGR666:include/uapi/linux/videodev2.h, line 575V4L2_PIX_FMT_BGRA32:include/uapi/linux/videodev2.h, line 581V4L2_PIX_FMT_BGRA444:include/uapi/linux/videodev2.h, line 557V4L2_PIX_FMT_BGRA555:include/uapi/linux/videodev2.h, line 566V4L2_PIX_FMT_BGRX32:include/uapi/linux/videodev2.h, line 582V4L2_PIX_FMT_BGRX444:include/uapi/linux/videodev2.h, line 558V4L2_PIX_FMT_BGRX555:include/uapi/linux/videodev2.h, line 567V4L2_PIX_FMT_CIT_YYVYUY:include/uapi/linux/videodev2.h, line 805V4L2_PIX_FMT_CNF4:include/uapi/linux/videodev2.h, line 819V4L2_PIX_FMT_CPIA1:include/uapi/linux/videodev2.h, line 784V4L2_PIX_FMT_DV:include/uapi/linux/videodev2.h, line 755V4L2_PIX_FMT_ET61X251:include/uapi/linux/videodev2.h, line 790V4L2_PIX_FMT_FLAG_PREMUL_ALPHA:include/uapi/linux/videodev2.h, line 910V4L2_PIX_FMT_FLAG_SET_CSC:include/uapi/linux/videodev2.h, line 911V4L2_PIX_FMT_FWHT:include/uapi/linux/videodev2.h, line 773V4L2_PIX_FMT_FWHT_STATELESS:include/uapi/linux/videodev2.h, line 774V4L2_PIX_FMT_GREY:include/uapi/linux/videodev2.h, line 599V4L2_PIX_FMT_H263:include/uapi/linux/videodev2.h, line 760V4L2_PIX_FMT_H264:include/uapi/linux/videodev2.h, line 757V4L2_PIX_FMT_H264_MVC:include/uapi/linux/videodev2.h, line 759V4L2_PIX_FMT_H264_NO_SC:include/uapi/linux/videodev2.h, line 758V4L2_PIX_FMT_H264_SLICE:include/uapi/linux/videodev2.h, line 775V4L2_PIX_FMT_HEVC:include/uapi/linux/videodev2.h, line 772V4L2_PIX_FMT_HEVC_SLICE:include/uapi/linux/videodev2.h, line 776V4L2_PIX_FMT_HEXTILE:include/uapi/linux/videodev2.h, line 824V4L2_PIX_FMT_HI240:include/uapi/linux/videodev2.h, line 820V4L2_PIX_FMT_HM12:include/uapi/linux/videodev2.h, line 2835V4L2_PIX_FMT_HSV24:include/uapi/linux/videodev2.h, line 749V4L2_PIX_FMT_HSV32:include/uapi/linux/videodev2.h, line 750V4L2_PIX_FMT_INZI:include/uapi/linux/videodev2.h, line 818V4L2_PIX_FMT_IPU3_SBGGR10:include/uapi/linux/videodev2.h, line 827V4L2_PIX_FMT_IPU3_SGBRG10:include/uapi/linux/videodev2.h, line 828V4L2_PIX_FMT_IPU3_SGRBG10:include/uapi/linux/videodev2.h, line 829V4L2_PIX_FMT_IPU3_SRGGB10:include/uapi/linux/videodev2.h, line 830V4L2_PIX_FMT_IPU3_Y10:include/uapi/linux/videodev2.h, line 612V4L2_PIX_FMT_JL2005BCD:include/uapi/linux/videodev2.h, line 797V4L2_PIX_FMT_JPEG:include/uapi/linux/videodev2.h, line 754V4L2_PIX_FMT_JPGL:include/uapi/linux/videodev2.h, line 807V4L2_PIX_FMT_KONICA420:include/uapi/linux/videodev2.h, line 806V4L2_PIX_FMT_M420:include/uapi/linux/videodev2.h, line 640V4L2_PIX_FMT_MJPEG:include/uapi/linux/videodev2.h, line 753V4L2_PIX_FMT_MM21:include/uapi/linux/videodev2.h, line 815V4L2_PIX_FMT_MPEG:include/uapi/linux/videodev2.h, line 756V4L2_PIX_FMT_MPEG1:include/uapi/linux/videodev2.h, line 761V4L2_PIX_FMT_MPEG2:include/uapi/linux/videodev2.h, line 762V4L2_PIX_FMT_MPEG2_SLICE:include/uapi/linux/videodev2.h, line 763V4L2_PIX_FMT_MPEG4:include/uapi/linux/videodev2.h, line 764V4L2_PIX_FMT_MR97310A:include/uapi/linux/videodev2.h, line 796V4L2_PIX_FMT_MT2110R:include/uapi/linux/videodev2.h, line 817V4L2_PIX_FMT_MT2110T:include/uapi/linux/videodev2.h, line 816V4L2_PIX_FMT_MT21C:include/uapi/linux/videodev2.h, line 814V4L2_PIX_FMT_NV12:include/uapi/linux/videodev2.h, line 652V4L2_PIX_FMT_NV12M:include/uapi/linux/videodev2.h, line 664V4L2_PIX_FMT_NV12MT:include/uapi/linux/videodev2.h, line 696V4L2_PIX_FMT_NV12MT_16X16:include/uapi/linux/videodev2.h, line 697V4L2_PIX_FMT_NV12M_10BE_8L128:include/uapi/linux/videodev2.h, line 699V4L2_PIX_FMT_NV12M_8L128:include/uapi/linux/videodev2.h, line 698V4L2_PIX_FMT_NV12_10BE_8L128:include/uapi/linux/videodev2.h, line 693V4L2_PIX_FMT_NV12_16L16:include/uapi/linux/videodev2.h, line 688V4L2_PIX_FMT_NV12_32L32:include/uapi/linux/videodev2.h, line 689V4L2_PIX_FMT_NV12_4L4:include/uapi/linux/videodev2.h, line 687V4L2_PIX_FMT_NV12_8L128:include/uapi/linux/videodev2.h, line 692V4L2_PIX_FMT_NV15:include/uapi/linux/videodev2.h, line 654V4L2_PIX_FMT_NV15_4L4:include/uapi/linux/videodev2.h, line 690V4L2_PIX_FMT_NV16:include/uapi/linux/videodev2.h, line 655V4L2_PIX_FMT_NV16M:include/uapi/linux/videodev2.h, line 666V4L2_PIX_FMT_NV20:include/uapi/linux/videodev2.h, line 657V4L2_PIX_FMT_NV21:include/uapi/linux/videodev2.h, line 653V4L2_PIX_FMT_NV21M:include/uapi/linux/videodev2.h, line 665V4L2_PIX_FMT_NV24:include/uapi/linux/videodev2.h, line 658V4L2_PIX_FMT_NV42:include/uapi/linux/videodev2.h, line 659V4L2_PIX_FMT_NV61:include/uapi/linux/videodev2.h, line 656V4L2_PIX_FMT_NV61M:include/uapi/linux/videodev2.h, line 667V4L2_PIX_FMT_OV511:include/uapi/linux/videodev2.h, line 801V4L2_PIX_FMT_OV518:include/uapi/linux/videodev2.h, line 802V4L2_PIX_FMT_P010:include/uapi/linux/videodev2.h, line 660V4L2_PIX_FMT_P010_4L4:include/uapi/linux/videodev2.h, line 691V4L2_PIX_FMT_P012:include/uapi/linux/videodev2.h, line 661V4L2_PIX_FMT_P012M:include/uapi/linux/videodev2.h, line 668V4L2_PIX_FMT_PAC207:include/uapi/linux/videodev2.h, line 795V4L2_PIX_FMT_PAL8:include/uapi/linux/videodev2.h, line 617V4L2_PIX_FMT_PISP_COMP1_BGGR:include/uapi/linux/videodev2.h, line 836V4L2_PIX_FMT_PISP_COMP1_GBRG:include/uapi/linux/videodev2.h, line 835V4L2_PIX_FMT_PISP_COMP1_GRBG:include/uapi/linux/videodev2.h, line 834V4L2_PIX_FMT_PISP_COMP1_MONO:include/uapi/linux/videodev2.h, line 837V4L2_PIX_FMT_PISP_COMP1_RGGB:include/uapi/linux/videodev2.h, line 833V4L2_PIX_FMT_PISP_COMP2_BGGR:include/uapi/linux/videodev2.h, line 841V4L2_PIX_FMT_PISP_COMP2_GBRG:include/uapi/linux/videodev2.h, line 840V4L2_PIX_FMT_PISP_COMP2_GRBG:include/uapi/linux/videodev2.h, line 839V4L2_PIX_FMT_PISP_COMP2_MONO:include/uapi/linux/videodev2.h, line 842V4L2_PIX_FMT_PISP_COMP2_RGGB:include/uapi/linux/videodev2.h, line 838V4L2_PIX_FMT_PJPG:include/uapi/linux/videodev2.h, line 800V4L2_PIX_FMT_PRIV_MAGIC:include/uapi/linux/videodev2.h, line 907V4L2_PIX_FMT_PWC1:include/uapi/linux/videodev2.h, line 788V4L2_PIX_FMT_PWC2:include/uapi/linux/videodev2.h, line 789V4L2_PIX_FMT_QC08C:include/uapi/linux/videodev2.h, line 821V4L2_PIX_FMT_QC10C:include/uapi/linux/videodev2.h, line 822V4L2_PIX_FMT_RAW_CRU10:include/uapi/linux/videodev2.h, line 845V4L2_PIX_FMT_RAW_CRU12:include/uapi/linux/videodev2.h, line 846V4L2_PIX_FMT_RAW_CRU14:include/uapi/linux/videodev2.h, line 847V4L2_PIX_FMT_RAW_CRU20:include/uapi/linux/videodev2.h, line 848V4L2_PIX_FMT_RGB24:include/uapi/linux/videodev2.h, line 577V4L2_PIX_FMT_RGB32:include/uapi/linux/videodev2.h, line 583V4L2_PIX_FMT_RGB332:include/uapi/linux/videodev2.h, line 549V4L2_PIX_FMT_RGB444:include/uapi/linux/videodev2.h, line 550V4L2_PIX_FMT_RGB48:include/uapi/linux/videodev2.h, line 595V4L2_PIX_FMT_RGB555:include/uapi/linux/videodev2.h, line 559V4L2_PIX_FMT_RGB555X:include/uapi/linux/videodev2.h, line 569V4L2_PIX_FMT_RGB565:include/uapi/linux/videodev2.h, line 568V4L2_PIX_FMT_RGB565X:include/uapi/linux/videodev2.h, line 572V4L2_PIX_FMT_RGBA1010102:include/uapi/linux/videodev2.h, line 589V4L2_PIX_FMT_RGBA32:include/uapi/linux/videodev2.h, line 584V4L2_PIX_FMT_RGBA444:include/uapi/linux/videodev2.h, line 553V4L2_PIX_FMT_RGBA555:include/uapi/linux/videodev2.h, line 562V4L2_PIX_FMT_RGBX1010102:include/uapi/linux/videodev2.h, line 588V4L2_PIX_FMT_RGBX32:include/uapi/linux/videodev2.h, line 585V4L2_PIX_FMT_RGBX444:include/uapi/linux/videodev2.h, line 554V4L2_PIX_FMT_RGBX555:include/uapi/linux/videodev2.h, line 563V4L2_PIX_FMT_RV30:include/uapi/linux/videodev2.h, line 780V4L2_PIX_FMT_RV40:include/uapi/linux/videodev2.h, line 781V4L2_PIX_FMT_S5C_UYVY_JPG:include/uapi/linux/videodev2.h, line 809V4L2_PIX_FMT_SBGGR10:include/uapi/linux/videodev2.h, line 706V4L2_PIX_FMT_SBGGR10ALAW8:include/uapi/linux/videodev2.h, line 716V4L2_PIX_FMT_SBGGR10DPCM8:include/uapi/linux/videodev2.h, line 721V4L2_PIX_FMT_SBGGR10P:include/uapi/linux/videodev2.h, line 711V4L2_PIX_FMT_SBGGR12:include/uapi/linux/videodev2.h, line 725V4L2_PIX_FMT_SBGGR12P:include/uapi/linux/videodev2.h, line 730V4L2_PIX_FMT_SBGGR14:include/uapi/linux/videodev2.h, line 734V4L2_PIX_FMT_SBGGR14P:include/uapi/linux/videodev2.h, line 739V4L2_PIX_FMT_SBGGR16:include/uapi/linux/videodev2.h, line 743V4L2_PIX_FMT_SBGGR8:include/uapi/linux/videodev2.h, line 702V4L2_PIX_FMT_SE401:include/uapi/linux/videodev2.h, line 808V4L2_PIX_FMT_SGBRG10:include/uapi/linux/videodev2.h, line 707V4L2_PIX_FMT_SGBRG10ALAW8:include/uapi/linux/videodev2.h, line 717V4L2_PIX_FMT_SGBRG10DPCM8:include/uapi/linux/videodev2.h, line 722V4L2_PIX_FMT_SGBRG10P:include/uapi/linux/videodev2.h, line 712V4L2_PIX_FMT_SGBRG12:include/uapi/linux/videodev2.h, line 726V4L2_PIX_FMT_SGBRG12P:include/uapi/linux/videodev2.h, line 731V4L2_PIX_FMT_SGBRG14:include/uapi/linux/videodev2.h, line 735V4L2_PIX_FMT_SGBRG14P:include/uapi/linux/videodev2.h, line 740V4L2_PIX_FMT_SGBRG16:include/uapi/linux/videodev2.h, line 744V4L2_PIX_FMT_SGBRG8:include/uapi/linux/videodev2.h, line 703V4L2_PIX_FMT_SGRBG10:include/uapi/linux/videodev2.h, line 708V4L2_PIX_FMT_SGRBG10ALAW8:include/uapi/linux/videodev2.h, line 718V4L2_PIX_FMT_SGRBG10DPCM8:include/uapi/linux/videodev2.h, line 723V4L2_PIX_FMT_SGRBG10P:include/uapi/linux/videodev2.h, line 713V4L2_PIX_FMT_SGRBG12:include/uapi/linux/videodev2.h, line 727V4L2_PIX_FMT_SGRBG12P:include/uapi/linux/videodev2.h, line 732V4L2_PIX_FMT_SGRBG14:include/uapi/linux/videodev2.h, line 736V4L2_PIX_FMT_SGRBG14P:include/uapi/linux/videodev2.h, line 741V4L2_PIX_FMT_SGRBG16:include/uapi/linux/videodev2.h, line 745V4L2_PIX_FMT_SGRBG8:include/uapi/linux/videodev2.h, line 704V4L2_PIX_FMT_SN9C10X:include/uapi/linux/videodev2.h, line 786V4L2_PIX_FMT_SN9C2028:include/uapi/linux/videodev2.h, line 798V4L2_PIX_FMT_SN9C20X_I420:include/uapi/linux/videodev2.h, line 787V4L2_PIX_FMT_SPCA501:include/uapi/linux/videodev2.h, line 791V4L2_PIX_FMT_SPCA505:include/uapi/linux/videodev2.h, line 792V4L2_PIX_FMT_SPCA508:include/uapi/linux/videodev2.h, line 793V4L2_PIX_FMT_SPCA561:include/uapi/linux/videodev2.h, line 794V4L2_PIX_FMT_SPK:include/uapi/linux/videodev2.h, line 779V4L2_PIX_FMT_SQ905C:include/uapi/linux/videodev2.h, line 799V4L2_PIX_FMT_SRGGB10:include/uapi/linux/videodev2.h, line 709V4L2_PIX_FMT_SRGGB10ALAW8:include/uapi/linux/videodev2.h, line 719V4L2_PIX_FMT_SRGGB10DPCM8:include/uapi/linux/videodev2.h, line 724V4L2_PIX_FMT_SRGGB10P:include/uapi/linux/videodev2.h, line 714V4L2_PIX_FMT_SRGGB12:include/uapi/linux/videodev2.h, line 728V4L2_PIX_FMT_SRGGB12P:include/uapi/linux/videodev2.h, line 733V4L2_PIX_FMT_SRGGB14:include/uapi/linux/videodev2.h, line 737V4L2_PIX_FMT_SRGGB14P:include/uapi/linux/videodev2.h, line 742V4L2_PIX_FMT_SRGGB16:include/uapi/linux/videodev2.h, line 746V4L2_PIX_FMT_SRGGB8:include/uapi/linux/videodev2.h, line 705V4L2_PIX_FMT_STV0680:include/uapi/linux/videodev2.h, line 803V4L2_PIX_FMT_SUNXI_TILED_NV12:include/uapi/linux/videodev2.h, line 2836V4L2_PIX_FMT_TM6000:include/uapi/linux/videodev2.h, line 804V4L2_PIX_FMT_UV8:include/uapi/linux/videodev2.h, line 620V4L2_PIX_FMT_UYVY:include/uapi/linux/videodev2.h, line 626V4L2_PIX_FMT_VC1_ANNEX_G:include/uapi/linux/videodev2.h, line 766V4L2_PIX_FMT_VC1_ANNEX_L:include/uapi/linux/videodev2.h, line 767V4L2_PIX_FMT_VP8:include/uapi/linux/videodev2.h, line 768V4L2_PIX_FMT_VP8_FRAME:include/uapi/linux/videodev2.h, line 769V4L2_PIX_FMT_VP9:include/uapi/linux/videodev2.h, line 770V4L2_PIX_FMT_VP9_FRAME:include/uapi/linux/videodev2.h, line 771V4L2_PIX_FMT_VUYA32:include/uapi/linux/videodev2.h, line 636V4L2_PIX_FMT_VUYX32:include/uapi/linux/videodev2.h, line 637V4L2_PIX_FMT_VYUY:include/uapi/linux/videodev2.h, line 627V4L2_PIX_FMT_WNVA:include/uapi/linux/videodev2.h, line 785V4L2_PIX_FMT_XBGR32:include/uapi/linux/videodev2.h, line 580V4L2_PIX_FMT_XBGR444:include/uapi/linux/videodev2.h, line 556V4L2_PIX_FMT_XBGR555:include/uapi/linux/videodev2.h, line 565V4L2_PIX_FMT_XRGB32:include/uapi/linux/videodev2.h, line 587V4L2_PIX_FMT_XRGB444:include/uapi/linux/videodev2.h, line 552V4L2_PIX_FMT_XRGB555:include/uapi/linux/videodev2.h, line 561V4L2_PIX_FMT_XRGB555X:include/uapi/linux/videodev2.h, line 571V4L2_PIX_FMT_XVID:include/uapi/linux/videodev2.h, line 765V4L2_PIX_FMT_XYUV32:include/uapi/linux/videodev2.h, line 635V4L2_PIX_FMT_Y012:include/uapi/linux/videodev2.h, line 604V4L2_PIX_FMT_Y10:include/uapi/linux/videodev2.h, line 602V4L2_PIX_FMT_Y10BPACK:include/uapi/linux/videodev2.h, line 610V4L2_PIX_FMT_Y10P:include/uapi/linux/videodev2.h, line 611V4L2_PIX_FMT_Y12:include/uapi/linux/videodev2.h, line 603V4L2_PIX_FMT_Y12I:include/uapi/linux/videodev2.h, line 811V4L2_PIX_FMT_Y12P:include/uapi/linux/videodev2.h, line 613V4L2_PIX_FMT_Y14:include/uapi/linux/videodev2.h, line 605V4L2_PIX_FMT_Y14P:include/uapi/linux/videodev2.h, line 614V4L2_PIX_FMT_Y16:include/uapi/linux/videodev2.h, line 606V4L2_PIX_FMT_Y16I:include/uapi/linux/videodev2.h, line 812V4L2_PIX_FMT_Y16_BE:include/uapi/linux/videodev2.h, line 607V4L2_PIX_FMT_Y210:include/uapi/linux/videodev2.h, line 647V4L2_PIX_FMT_Y212:include/uapi/linux/videodev2.h, line 648V4L2_PIX_FMT_Y216:include/uapi/linux/videodev2.h, line 649V4L2_PIX_FMT_Y4:include/uapi/linux/videodev2.h, line 600V4L2_PIX_FMT_Y41P:include/uapi/linux/videodev2.h, line 628V4L2_PIX_FMT_Y6:include/uapi/linux/videodev2.h, line 601V4L2_PIX_FMT_Y8I:include/uapi/linux/videodev2.h, line 810V4L2_PIX_FMT_YUV24:include/uapi/linux/videodev2.h, line 632V4L2_PIX_FMT_YUV32:include/uapi/linux/videodev2.h, line 633V4L2_PIX_FMT_YUV410:include/uapi/linux/videodev2.h, line 671V4L2_PIX_FMT_YUV411P:include/uapi/linux/videodev2.h, line 673V4L2_PIX_FMT_YUV420:include/uapi/linux/videodev2.h, line 674V4L2_PIX_FMT_YUV420M:include/uapi/linux/videodev2.h, line 679V4L2_PIX_FMT_YUV422M:include/uapi/linux/videodev2.h, line 681V4L2_PIX_FMT_YUV422P:include/uapi/linux/videodev2.h, line 676V4L2_PIX_FMT_YUV444:include/uapi/linux/videodev2.h, line 629V4L2_PIX_FMT_YUV444M:include/uapi/linux/videodev2.h, line 683V4L2_PIX_FMT_YUV48_12:include/uapi/linux/videodev2.h, line 641V4L2_PIX_FMT_YUV555:include/uapi/linux/videodev2.h, line 630V4L2_PIX_FMT_YUV565:include/uapi/linux/videodev2.h, line 631V4L2_PIX_FMT_YUVA32:include/uapi/linux/videodev2.h, line 638V4L2_PIX_FMT_YUVX32:include/uapi/linux/videodev2.h, line 639V4L2_PIX_FMT_YUYV:include/uapi/linux/videodev2.h, line 623V4L2_PIX_FMT_YVU410:include/uapi/linux/videodev2.h, line 672V4L2_PIX_FMT_YVU420:include/uapi/linux/videodev2.h, line 675V4L2_PIX_FMT_YVU420M:include/uapi/linux/videodev2.h, line 680V4L2_PIX_FMT_YVU422M:include/uapi/linux/videodev2.h, line 682V4L2_PIX_FMT_YVU444M:include/uapi/linux/videodev2.h, line 684V4L2_PIX_FMT_YVYU:include/uapi/linux/videodev2.h, line 625V4L2_PIX_FMT_YYUV:include/uapi/linux/videodev2.h, line 624V4L2_PIX_FMT_Z16:include/uapi/linux/videodev2.h, line 813V4L2_RDS_BLOCK_A:include/uapi/linux/videodev2.h, line 2168V4L2_RDS_BLOCK_B:include/uapi/linux/videodev2.h, line 2169V4L2_RDS_BLOCK_C:include/uapi/linux/videodev2.h, line 2170V4L2_RDS_BLOCK_CORRECTED:include/uapi/linux/videodev2.h, line 2175V4L2_RDS_BLOCK_C_ALT:include/uapi/linux/videodev2.h, line 2172V4L2_RDS_BLOCK_D:include/uapi/linux/videodev2.h, line 2171V4L2_RDS_BLOCK_ERROR:include/uapi/linux/videodev2.h, line 2176V4L2_RDS_BLOCK_INVALID:include/uapi/linux/videodev2.h, line 2173V4L2_RDS_BLOCK_MSK:include/uapi/linux/videodev2.h, line 2167V4L2_SDR_FMT_CS14LE:include/uapi/linux/videodev2.h, line 854V4L2_SDR_FMT_CS8:include/uapi/linux/videodev2.h, line 853V4L2_SDR_FMT_CU16LE:include/uapi/linux/videodev2.h, line 852V4L2_SDR_FMT_CU8:include/uapi/linux/videodev2.h, line 851V4L2_SDR_FMT_PCU16BE:include/uapi/linux/videodev2.h, line 856V4L2_SDR_FMT_PCU18BE:include/uapi/linux/videodev2.h, line 857V4L2_SDR_FMT_PCU20BE:include/uapi/linux/videodev2.h, line 858V4L2_SDR_FMT_RU12LE:include/uapi/linux/videodev2.h, line 855V4L2_SLICED_CAPTION_525:include/uapi/linux/videodev2.h, line 2352V4L2_SLICED_TELETEXT_B:include/uapi/linux/videodev2.h, line 2348V4L2_SLICED_VBI_525:include/uapi/linux/videodev2.h, line 2356V4L2_SLICED_VBI_625:include/uapi/linux/videodev2.h, line 2357V4L2_SLICED_VPS:include/uapi/linux/videodev2.h, line 2350V4L2_SLICED_WSS_625:include/uapi/linux/videodev2.h, line 2354V4L2_STD_525_60:include/uapi/linux/videodev2.h, line 1526V4L2_STD_625_50:include/uapi/linux/videodev2.h, line 1531V4L2_STD_ALL:include/uapi/linux/videodev2.h, line 1540V4L2_STD_ATSC:include/uapi/linux/videodev2.h, line 1536V4L2_STD_ATSC_16_VSB:include/uapi/linux/videodev2.h, line 1448V4L2_STD_ATSC_8_VSB:include/uapi/linux/videodev2.h, line 1447V4L2_STD_B:include/uapi/linux/videodev2.h, line 1499V4L2_STD_BG:include/uapi/linux/videodev2.h, line 1512V4L2_STD_DK:include/uapi/linux/videodev2.h, line 1510V4L2_STD_G:include/uapi/linux/videodev2.h, line 1502V4L2_STD_GH:include/uapi/linux/videodev2.h, line 1508V4L2_STD_H:include/uapi/linux/videodev2.h, line 1504V4L2_STD_L:include/uapi/linux/videodev2.h, line 1506V4L2_STD_MN:include/uapi/linux/videodev2.h, line 1514V4L2_STD_MTS:include/uapi/linux/videodev2.h, line 1520V4L2_STD_NTSC:include/uapi/linux/videodev2.h, line 1468V4L2_STD_NTSC_443:include/uapi/linux/videodev2.h, line 1434V4L2_STD_NTSC_M:include/uapi/linux/videodev2.h, line 1432V4L2_STD_NTSC_M_JP:include/uapi/linux/videodev2.h, line 1433V4L2_STD_NTSC_M_KR:include/uapi/linux/videodev2.h, line 1435V4L2_STD_PAL:include/uapi/linux/videodev2.h, line 1494V4L2_STD_PAL_60:include/uapi/linux/videodev2.h, line 1430V4L2_STD_PAL_B:include/uapi/linux/videodev2.h, line 1418V4L2_STD_PAL_B1:include/uapi/linux/videodev2.h, line 1419V4L2_STD_PAL_BG:include/uapi/linux/videodev2.h, line 1483V4L2_STD_PAL_D:include/uapi/linux/videodev2.h, line 1423V4L2_STD_PAL_D1:include/uapi/linux/videodev2.h, line 1424V4L2_STD_PAL_DK:include/uapi/linux/videodev2.h, line 1486V4L2_STD_PAL_G:include/uapi/linux/videodev2.h, line 1420V4L2_STD_PAL_H:include/uapi/linux/videodev2.h, line 1421V4L2_STD_PAL_I:include/uapi/linux/videodev2.h, line 1422V4L2_STD_PAL_K:include/uapi/linux/videodev2.h, line 1425V4L2_STD_PAL_M:include/uapi/linux/videodev2.h, line 1427V4L2_STD_PAL_N:include/uapi/linux/videodev2.h, line 1428V4L2_STD_PAL_Nc:include/uapi/linux/videodev2.h, line 1429V4L2_STD_SECAM:include/uapi/linux/videodev2.h, line 1476V4L2_STD_SECAM_B:include/uapi/linux/videodev2.h, line 1437V4L2_STD_SECAM_D:include/uapi/linux/videodev2.h, line 1438V4L2_STD_SECAM_DK:include/uapi/linux/videodev2.h, line 1472V4L2_STD_SECAM_G:include/uapi/linux/videodev2.h, line 1439V4L2_STD_SECAM_H:include/uapi/linux/videodev2.h, line 1440V4L2_STD_SECAM_K:include/uapi/linux/videodev2.h, line 1441V4L2_STD_SECAM_K1:include/uapi/linux/videodev2.h, line 1442V4L2_STD_SECAM_L:include/uapi/linux/videodev2.h, line 1443V4L2_STD_SECAM_LC:include/uapi/linux/videodev2.h, line 1444V4L2_STD_UNKNOWN:include/uapi/linux/videodev2.h, line 1539V4L2_TCH_FMT_DELTA_TD08:include/uapi/linux/videodev2.h, line 862V4L2_TCH_FMT_DELTA_TD16:include/uapi/linux/videodev2.h, line 861V4L2_TCH_FMT_TU08:include/uapi/linux/videodev2.h, line 864V4L2_TCH_FMT_TU16:include/uapi/linux/videodev2.h, line 863V4L2_TC_FLAG_COLORFRAME:include/uapi/linux/videodev2.h, line 1030V4L2_TC_FLAG_DROPFRAME:include/uapi/linux/videodev2.h, line 1029V4L2_TC_TYPE_24FPS:include/uapi/linux/videodev2.h, line 1022V4L2_TC_TYPE_25FPS:include/uapi/linux/videodev2.h, line 1023V4L2_TC_TYPE_30FPS:include/uapi/linux/videodev2.h, line 1024V4L2_TC_TYPE_50FPS:include/uapi/linux/videodev2.h, line 1025V4L2_TC_TYPE_60FPS:include/uapi/linux/videodev2.h, line 1026V4L2_TC_USERBITS_8BITCHARS:include/uapi/linux/videodev2.h, line 1033V4L2_TC_USERBITS_USERDEFINED:include/uapi/linux/videodev2.h, line 1032V4L2_TC_USERBITS_field:include/uapi/linux/videodev2.h, line 1031V4L2_TUNER_CAP_1HZ:include/uapi/linux/videodev2.h, line 2106V4L2_TUNER_CAP_FREQ_BANDS:include/uapi/linux/videodev2.h, line 2104V4L2_TUNER_CAP_HWSEEK_BOUNDED:include/uapi/linux/videodev2.h, line 2095V4L2_TUNER_CAP_HWSEEK_PROG_LIM:include/uapi/linux/videodev2.h, line 2105V4L2_TUNER_CAP_HWSEEK_WRAP:include/uapi/linux/videodev2.h, line 2096V4L2_TUNER_CAP_LANG1:include/uapi/linux/videodev2.h, line 2100V4L2_TUNER_CAP_LANG2:include/uapi/linux/videodev2.h, line 2098V4L2_TUNER_CAP_LOW:include/uapi/linux/videodev2.h, line 2093V4L2_TUNER_CAP_NORM:include/uapi/linux/videodev2.h, line 2094V4L2_TUNER_CAP_RDS:include/uapi/linux/videodev2.h, line 2101V4L2_TUNER_CAP_RDS_BLOCK_IO:include/uapi/linux/videodev2.h, line 2102V4L2_TUNER_CAP_RDS_CONTROLS:include/uapi/linux/videodev2.h, line 2103V4L2_TUNER_CAP_SAP:include/uapi/linux/videodev2.h, line 2099V4L2_TUNER_CAP_STEREO:include/uapi/linux/videodev2.h, line 2097V4L2_TUNER_MODE_LANG1:include/uapi/linux/videodev2.h, line 2121V4L2_TUNER_MODE_LANG1_LANG2:include/uapi/linux/videodev2.h, line 2122V4L2_TUNER_MODE_LANG2:include/uapi/linux/videodev2.h, line 2119V4L2_TUNER_MODE_MONO:include/uapi/linux/videodev2.h, line 2117V4L2_TUNER_MODE_SAP:include/uapi/linux/videodev2.h, line 2120V4L2_TUNER_MODE_STEREO:include/uapi/linux/videodev2.h, line 2118V4L2_TUNER_SUB_LANG1:include/uapi/linux/videodev2.h, line 2113V4L2_TUNER_SUB_LANG2:include/uapi/linux/videodev2.h, line 2111V4L2_TUNER_SUB_MONO:include/uapi/linux/videodev2.h, line 2109V4L2_TUNER_SUB_RDS:include/uapi/linux/videodev2.h, line 2114V4L2_TUNER_SUB_SAP:include/uapi/linux/videodev2.h, line 2112V4L2_TUNER_SUB_STEREO:include/uapi/linux/videodev2.h, line 2110V4L2_VBI_INTERLACED:include/uapi/linux/videodev2.h, line 2320V4L2_VBI_ITU_525_F1_START:include/uapi/linux/videodev2.h, line 2323V4L2_VBI_ITU_525_F2_START:include/uapi/linux/videodev2.h, line 2324V4L2_VBI_ITU_625_F1_START:include/uapi/linux/videodev2.h, line 2325V4L2_VBI_ITU_625_F2_START:include/uapi/linux/videodev2.h, line 2326V4L2_VBI_UNSYNC:include/uapi/linux/videodev2.h, line 2319V4L2_XFER_FUNC_ADOBERGB:include/uapi/linux/videodev2.h, line 431
Structures #
v4l2_area:include/uapi/linux/videodev2.h, line 454v4l2_audio:include/uapi/linux/videodev2.h, line 2181v4l2_audioout:include/uapi/linux/videodev2.h, line 2196v4l2_bt_timings:include/uapi/linux/videodev2.h, line 1591v4l2_bt_timings_cap:include/uapi/linux/videodev2.h, line 1752v4l2_buffer:include/uapi/linux/videodev2.h, line 1178v4l2_capability:include/uapi/linux/videodev2.h, line 470v4l2_captureparm:include/uapi/linux/videodev2.h, line 1348v4l2_clip:include/uapi/linux/videodev2.h, line 1330v4l2_control:include/uapi/linux/videodev2.h, line 1869v4l2_create_buffers:include/uapi/linux/videodev2.h, line 2701v4l2_crop:include/uapi/linux/videodev2.h, line 1380v4l2_cropcap:include/uapi/linux/videodev2.h, line 1373v4l2_dbg_chip_info:include/uapi/linux/videodev2.h, line 2678v4l2_dbg_match:include/uapi/linux/videodev2.h, line 2659v4l2_dbg_register:include/uapi/linux/videodev2.h, line 2667v4l2_decoder_cmd:include/uapi/linux/videodev2.h, line 2274v4l2_dv_timings:include/uapi/linux/videodev2.h, line 1715v4l2_dv_timings_cap:include/uapi/linux/videodev2.h, line 1779v4l2_enc_idx:include/uapi/linux/videodev2.h, line 2222v4l2_enc_idx_entry:include/uapi/linux/videodev2.h, line 2213v4l2_encoder_cmd:include/uapi/linux/videodev2.h, line 2238v4l2_enum_dv_timings:include/uapi/linux/videodev2.h, line 1734v4l2_event:include/uapi/linux/videodev2.h, line 2610v4l2_event_ctrl:include/uapi/linux/videodev2.h, line 2571v4l2_event_frame_sync:include/uapi/linux/videodev2.h, line 2585v4l2_event_motion_det:include/uapi/linux/videodev2.h, line 2604v4l2_event_src_change:include/uapi/linux/videodev2.h, line 2591v4l2_event_subscription:include/uapi/linux/videodev2.h, line 2634v4l2_event_vsync:include/uapi/linux/videodev2.h, line 2560v4l2_exportbuffer:include/uapi/linux/videodev2.h, line 1281v4l2_ext_control:include/uapi/linux/videodev2.h, line 1874v4l2_ext_controls:include/uapi/linux/videodev2.h, line 1917v4l2_fmtdesc:include/uapi/linux/videodev2.h, line 916v4l2_format:include/uapi/linux/videodev2.h, line 2521v4l2_fract:include/uapi/linux/videodev2.h, line 449v4l2_framebuffer:include/uapi/linux/videodev2.h, line 1293v4l2_frequency:include/uapi/linux/videodev2.h, line 2124v4l2_frequency_band:include/uapi/linux/videodev2.h, line 2135v4l2_frmival_stepwise:include/uapi/linux/videodev2.h, line 987v4l2_frmivalenum:include/uapi/linux/videodev2.h, line 993v4l2_frmsize_discrete:include/uapi/linux/videodev2.h, line 951v4l2_frmsize_stepwise:include/uapi/linux/videodev2.h, line 956v4l2_frmsizeenum:include/uapi/linux/videodev2.h, line 965v4l2_hw_freq_seek:include/uapi/linux/videodev2.h, line 2146v4l2_input:include/uapi/linux/videodev2.h, line 1793v4l2_jpegcompression:include/uapi/linux/videodev2.h, line 1036v4l2_meta_format:include/uapi/linux/videodev2.h, line 2501v4l2_modulator:include/uapi/linux/videodev2.h, line 2081v4l2_mpeg_vbi_ITV0:include/uapi/linux/videodev2.h, line 2410v4l2_mpeg_vbi_fmt_ivtv:include/uapi/linux/videodev2.h, line 2417v4l2_mpeg_vbi_itv0:include/uapi/linux/videodev2.h, line 2405v4l2_mpeg_vbi_itv0_line:include/uapi/linux/videodev2.h, line 2400v4l2_output:include/uapi/linux/videodev2.h, line 1845v4l2_outputparm:include/uapi/linux/videodev2.h, line 1361v4l2_pix_format:include/uapi/linux/videodev2.h, line 526v4l2_pix_format_mplane:include/uapi/linux/videodev2.h, line 2459v4l2_plane:include/uapi/linux/videodev2.h, line 1131v4l2_plane_pix_format:include/uapi/linux/videodev2.h, line 2437v4l2_query_ext_ctrl:include/uapi/linux/videodev2.h, line 2012v4l2_queryctrl:include/uapi/linux/videodev2.h, line 1999v4l2_querymenu:include/uapi/linux/videodev2.h, line 2029v4l2_rds_data:include/uapi/linux/videodev2.h, line 2161v4l2_rect:include/uapi/linux/videodev2.h, line 442v4l2_remove_buffers:include/uapi/linux/videodev2.h, line 2719v4l2_requestbuffers:include/uapi/linux/videodev2.h, line 1087v4l2_sdr_format:include/uapi/linux/videodev2.h, line 2484v4l2_selection:include/uapi/linux/videodev2.h, line 1398v4l2_sliced_vbi_cap:include/uapi/linux/videodev2.h, line 2359v4l2_sliced_vbi_data:include/uapi/linux/videodev2.h, line 2370v4l2_sliced_vbi_format:include/uapi/linux/videodev2.h, line 2335v4l2_standard:include/uapi/linux/videodev2.h, line 1543v4l2_streamparm:include/uapi/linux/videodev2.h, line 2537v4l2_timecode:include/uapi/linux/videodev2.h, line 1011v4l2_tuner:include/uapi/linux/videodev2.h, line 2067v4l2_vbi_format:include/uapi/linux/videodev2.h, line 2307v4l2_window:include/uapi/linux/videodev2.h, line 1335
ioctl VIDIOC_CREATE_BUFS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_CREATE_BUFS - Create buffers for Memory Mapped or User Pointer or DMA Buffer I/O
Synopsis #
int ioctl(int fd, VIDIOC_CREATE_BUFS, struct v4l2_create_buffers *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_create_buffers.
Description #
This ioctl is used to create buffers for memory mapped or user pointer or DMA buffer I/O. It can be used as an alternative or in addition to the vidioc_reqbufs ioctl, when a tighter control over buffers is required. This ioctl can be called multiple times to create buffers of different sizes.
To allocate the device buffers applications must initialize the relevant fields of the struct v4l2_create_buffers structure. The count field must be set to the number of requested buffers, the memory field specifies the requested I/O method and the reserved array must be zeroed.
The format field specifies the image format that the buffers must be able to handle. The application has to fill in this struct v4l2_format. Usually this will be done using the VIDIOC_TRY_FMT or VIDIOC_G_FMT ioctls to ensure that the requested format is supported by the driver. Based on the format's type field the requested buffer size (for single-planar) or plane sizes (for multi-planar formats) will be used for the allocated buffers. The driver may return an error if the size(s) are not supported by the hardware (usually because they are too small).
The buffers created by this ioctl will have as minimum size the size defined by the format.pix.sizeimage field (or the corresponding fields for other format types). Usually if the format.pix.sizeimage field is less than the minimum required for the given format, then an error will be returned since drivers will typically not allow this. If it is larger, then the value will be used as-is. In other words, the driver may reject the requested size, but if it is accepted the driver will use it unchanged.
When the ioctl is called with a pointer to this structure the driver will attempt to allocate up to the requested number of buffers and store the actual number allocated and the starting index in the count and the index fields respectively. On return count can be smaller than the number requested.
v4l2_create_buffers
|
__u32 |
|
The starting buffer index, returned by the driver. |
|
__u32 |
|
The number of buffers requested or granted. If count == 0, then ioctl VIDIOC_CREATE_BUFS will set |
|
__u32 |
|
Applications set this field to |
|
struct |
|
Filled in by the application, preserved by the driver. |
|
__u32 |
|
Set by the driver. If 0, then the driver doesn't support capabilities. In that case all you know is that the driver is guaranteed to support If you want to just query the capabilities without making any other changes, then set |
|
__u32 |
|
Specifies additional buffer management attributes. See memory-flags. |
|
__u32 |
|
If the V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS capability flag is set this field indicates the maximum possible number of buffers for this queue. |
|
__u32 |
|
A place holder for future extensions. Drivers and applications must set the array to zero. |
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.
-
ENOMEM
No memory to allocate buffers for memory mapped I/O.
-
EINVAL
The buffer type (
format.typefield), requested I/O method (memory) or format (formatfield) is not valid.
ioctl VIDIOC_CROPCAP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_CROPCAP - Information about the video cropping and scaling abilities
Synopsis #
int ioctl(int fd, VIDIOC_CROPCAP, struct v4l2_cropcap *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_cropcap.
Description #
Applications use this function to query the cropping limits, the pixel aspect of images and to calculate scale factors. They set the type field of a v4l2_cropcap structure to the respective buffer (stream) type and call the ioctl VIDIOC_CROPCAP ioctl with a pointer to this structure. Drivers fill the rest of the structure. The results are constant except when switching the video standard. Remember this switch can occur implicit when switching the video input or output.
This ioctl must be implemented for video capture or output devices that support cropping and/or scaling and/or have non-square pixels, and for overlay devices.
v4l2_cropcap
|
__u32 |
|
Type of the data stream, set by the application. Only these types are valid here: |
|
struct v4l2_rect |
|
Defines the window within capturing or output is possible, this may exclude for example the horizontal and vertical blanking areas. The cropping rectangle cannot exceed these limits. Width and height are defined in pixels, the driver writer is free to choose origin and units of the coordinate system in the analog domain. |
|
struct v4l2_rect |
|
Default cropping rectangle, it shall cover the "whole picture". Assuming pixel aspect 1/1 this could be for example a 640 × 480 rectangle for NTSC, a 768 × 576 rectangle for PAL and SECAM centered over the active picture area. The same coordinate system as for |
|
struct |
|
This is the pixel aspect (y / x) when no scaling is applied, the ratio of the actual sampling frequency and the frequency required to get square pixels. When cropping coordinates refer to square pixels, the driver sets |
|
__s32 |
|
Horizontal offset of the top, left corner of the rectangle, in pixels. |
|
__s32 |
|
Vertical offset of the top, left corner of the rectangle, in pixels. |
|
__u32 |
|
Width of the rectangle, in pixels. |
|
__u32 |
|
Height of the rectangle, in pixels. |
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.
-
EINVAL
The struct
v4l2_cropcaptypeis invalid. -
ENODATA
Cropping is not supported for this input or output.
ioctl VIDIOC_DBG_G_CHIP_INFO
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_DBG_G_CHIP_INFO - Identify the chips on a TV card
Synopsis #
int ioctl(int fd, VIDIOC_DBG_G_CHIP_INFO, struct v4l2_dbg_chip_info *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_dbg_chip_info.
Description #
For driver debugging purposes this ioctl allows test applications to query the driver about the chips present on the TV card. Regular applications must not use it. When you found a chip specific bug, please contact the linux-media mailing list (https://linuxtv.org/lists.php) so it can be fixed.
Additionally the Linux kernel must be compiled with the CONFIG_VIDEO_ADV_DEBUG option to enable this ioctl.
To query the driver applications must initialize the match.type and match.addr or match.name fields of a struct v4l2_dbg_chip_info and call ioctl VIDIOC_DBG_G_CHIP_INFO with a pointer to this structure. On success the driver stores information about the selected chip in the name and flags fields.
When match.type is V4L2_CHIP_MATCH_BRIDGE, match.addr selects the nth bridge 'chip' on the TV card. You can enumerate all chips by starting at zero and incrementing match.addr by one until ioctl VIDIOC_DBG_G_CHIP_INFO fails with an EINVAL error code. The number zero always selects the bridge chip itself, e. g. the chip connected to the PCI or USB bus. Non-zero numbers identify specific parts of the bridge chip such as an AC97 register block.
When match.type is V4L2_CHIP_MATCH_SUBDEV, match.addr selects the nth sub-device. This allows you to enumerate over all sub-devices.
On success, the name field will contain a chip name and the flags field will contain V4L2_CHIP_FL_READABLE if the driver supports reading registers from the device or V4L2_CHIP_FL_WRITABLE if the driver supports writing registers to the device.
We recommended the v4l2-dbg utility over calling this ioctl directly. It is available from the LinuxTV v4l-dvb repository; see https://linuxtv.org/repo/ for access instructions.
|
__u32 |
|
See name-chip-match-types for a list of possible types. |
|
union { |
(anonymous) |
|
|
__u32 |
|
Match a chip by this number, interpreted according to the |
|
char |
|
Match a chip by this name, interpreted according to the |
|
} |
||
v4l2_dbg_chip_info
|
struct v4l2_dbg_match |
|
How to match the chip, see name-v4l2-dbg-match. |
|
char |
|
The name of the chip. |
|
__u32 |
|
Set by the driver. If |
|
__u32 |
|
Reserved fields, both application and driver must set these to 0. |
|
|
0 |
Match the nth chip on the card, zero for the bridge chip. Does not match sub-devices. |
|
|
4 |
Match the nth sub-device. |
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.
-
EINVAL
The
match_typeis invalid or no device could be matched.
ioctl VIDIOC_DBG_G_REGISTER, VIDIOC_DBG_S_REGISTER
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Peios: Linux capability names in this interface retain their API meaning, but KACS evaluates them through native token privileges or compatibility rules. UID 0,
setcapand Unix mode bits do not independently grant native authority. Object access and PIP checks remain additional constraints where applicable. See Peios kernel behaviour for the mapping and exceptions.
Name #
VIDIOC_DBG_G_REGISTER - VIDIOC_DBG_S_REGISTER - Read or write hardware registers
Synopsis #
int ioctl(int fd, VIDIOC_DBG_G_REGISTER, struct v4l2_dbg_register *argp)
int ioctl(int fd, VIDIOC_DBG_S_REGISTER, const struct v4l2_dbg_register *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_dbg_register.
Description #
For driver debugging purposes these ioctls allow test applications to access hardware registers directly. Regular applications must not use them.
Since writing or even reading registers can jeopardize the system security, its stability and damage the hardware, both ioctls require superuser privileges. Additionally the Linux kernel must be compiled with the CONFIG_VIDEO_ADV_DEBUG option to enable these ioctls.
To write a register applications must initialize all fields of a struct v4l2_dbg_register except for size and call VIDIOC_DBG_S_REGISTER with a pointer to this structure. The match.type and match.addr or match.name fields select a chip on the TV card, the reg field specifies a register number and the val field the value to be written into the register.
To read a register applications must initialize the match.type, match.addr or match.name and reg fields, and call VIDIOC_DBG_G_REGISTER with a pointer to this structure. On success the driver stores the register value in the val field and the size (in bytes) of the value in size.
When match.type is V4L2_CHIP_MATCH_BRIDGE, match.addr selects the nth non-sub-device chip on the TV card. The number zero always selects the host chip, e. g. the chip connected to the PCI or USB bus. You can find out which chips are present with the ioctl VIDIOC_DBG_G_CHIP_INFO ioctl.
When match.type is V4L2_CHIP_MATCH_SUBDEV, match.addr selects the nth sub-device.
These ioctls are optional, not all drivers may support them. However when a driver supports these ioctls it must also support ioctl VIDIOC_DBG_G_CHIP_INFO. Conversely it may support VIDIOC_DBG_G_CHIP_INFO but not these ioctls.
VIDIOC_DBG_G_REGISTER and VIDIOC_DBG_S_REGISTER were introduced in Linux 2.6.21, but their API was changed to the one described here in kernel 2.6.29.
We recommended the v4l2-dbg utility over calling these ioctls directly. It is available from the LinuxTV v4l-dvb repository; see https://linuxtv.org/repo/ for access instructions.
v4l2_dbg_match
|
__u32 |
|
See chip-match-types for a list of possible types. |
|
union { |
(anonymous) |
|
|
__u32 |
|
Match a chip by this number, interpreted according to the |
|
char |
|
Match a chip by this name, interpreted according to the |
|
} |
||
v4l2_dbg_register
|
struct v4l2_dbg_match |
|
How to match the chip, see |
|
__u32 |
|
The register size in bytes. |
|
__u64 |
|
A register number. |
|
__u64 |
|
The value read from, or to be written into the register. |
|
|
0 |
Match the nth chip on the card, zero for the bridge chip. Does not match sub-devices. |
|
|
4 |
Match the nth sub-device. |
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.
-
EPERM
Insufficient permissions. Root privileges are required to execute these ioctls.
ioctl VIDIOC_DECODER_CMD, VIDIOC_TRY_DECODER_CMD
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_DECODER_CMD - VIDIOC_TRY_DECODER_CMD - Execute an decoder command
Synopsis #
int ioctl(int fd, VIDIOC_DECODER_CMD, struct v4l2_decoder_cmd *argp)
int ioctl(int fd, VIDIOC_TRY_DECODER_CMD, struct v4l2_decoder_cmd *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argppointer to struct
v4l2_decoder_cmd.
Description #
These ioctls control an audio/video (usually MPEG-) decoder. VIDIOC_DECODER_CMD sends a command to the decoder, VIDIOC_TRY_DECODER_CMD can be used to try a command without actually executing it. To send a command applications must initialize all fields of a struct v4l2_decoder_cmd and call VIDIOC_DECODER_CMD or VIDIOC_TRY_DECODER_CMD with a pointer to this structure.
The cmd field must contain the command code. Some commands use the flags field for additional information.
A write() or ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF call sends an implicit START command to the decoder if it has not been started yet. Applies to both queues of mem2mem decoders.
A close() or VIDIOC_STREAMOFF call of a streaming file descriptor sends an implicit immediate STOP command to the decoder, and all buffered data is discarded. Applies to both queues of mem2mem decoders.
In principle, these ioctls are optional, not all drivers may support them. They were introduced in Linux 3.3. They are, however, mandatory for stateful mem2mem decoders (as further documented in Memory-to-Memory Stateful Video Decoder Interface).
v4l2_decoder_cmd
|
__u32 |
|
The decoder command, see decoder-cmds. |
|
|
__u32 |
|
Flags to go with the command. If no flags are defined for this command, drivers and applications must set this field to zero. |
|
|
union { |
(anonymous) |
||
|
struct |
|
Structure containing additional data for the |
|
|
__s32 |
|
Playback speed and direction. The playback speed is defined as |
|
|
__u32 |
|
Format restrictions. This field is set by the driver, not the application. Possible values are |
|
|
struct |
|
Structure containing additional data for the |
|
|
__u64 |
|
Stop playback at this |
|
|
struct |
|
||
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
|
} |
|||
|
|
0 |
Start the decoder. When the decoder is already running or paused, this command will just change the playback speed. That means that calling For a device implementing the Memory-to-Memory Stateful Video Decoder Interface, once the drain sequence is initiated with the |
|
|
1 |
Stop the decoder. When the decoder is already stopped, this command does nothing. This command has two flags: if For a device implementing the Memory-to-Memory Stateful Video Decoder Interface, the command will initiate the drain sequence as documented in Memory-to-Memory Stateful Video Decoder Interface. No flags or other arguments are accepted in this case. Any attempt to invoke the command again before the sequence completes will trigger an |
|
|
2 |
Pause the decoder. When the decoder has not been started yet, the driver will return an |
|
|
3 |
Resume decoding after a PAUSE command. When the decoder has not been started yet, the driver will return an |
|
|
4 |
Flush any held capture buffers. Only valid for stateless decoders. This command is typically used when the application reached the end of the stream and the last output buffer had the |
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.
-
EBUSY
A drain sequence of a device implementing the Memory-to-Memory Stateful Video Decoder Interface is still in progress. It is not allowed to issue another decoder command until it completes.
-
EINVAL
The
cmdfield is invalid. -
EPERM
The application sent a PAUSE or RESUME command when the decoder was not running.
ioctl VIDIOC_DQEVENT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_DQEVENT - Dequeue event
Synopsis #
int ioctl(int fd, VIDIOC_DQEVENT, struct v4l2_event *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_event.
Description #
Dequeue an event from a video device. No input is required for this ioctl. All the fields of the struct v4l2_event structure are filled by the driver. The file handle will also receive exceptions which the application may get by e.g. using the select system call.
v4l2_event
|
__u32 |
|
Type of the event, see event-type. |
|
union { |
|
|
|
struct |
|
Event data for event |
|
struct |
|
Event data for event |
|
struct |
|
Event data for event |
|
struct |
|
Event data for event V4L2_EVENT_MOTION_DET. |
|
struct |
|
Event data for event V4L2_EVENT_SOURCE_CHANGE. |
|
__u8 |
|
Event data. Defined by the event type. The union should be used to define easily accessible type for events. |
|
} |
||
|
__u32 |
|
Number of pending events excluding this one. |
|
__u32 |
|
Event sequence number. The sequence number is incremented for every subscribed event that takes place. If sequence numbers are not contiguous it means that events have been lost. |
|
struct timespec |
|
Event timestamp. The timestamp has been taken from the |
|
u32 |
|
The ID associated with the event source. If the event does not have an associated ID (this depends on the event type), then this is 0. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
|
|
0 |
All events. V4L2_EVENT_ALL is valid only for VIDIOC_UNSUBSCRIBE_EVENT for unsubscribing all events at once. |
|
|
1 |
This event is triggered on the vertical sync. This event has a struct |
|
|
2 |
This event is triggered when the end of a stream is reached. This is typically used with MPEG decoders to report to the application when the last of the MPEG stream has been decoded. |
|
|
3 |
This event requires that the If the event is generated due to a call to VIDIOC_S_CTRL or VIDIOC_S_EXT_CTRLS, then the event will not be sent to the file handle that called the ioctl function. This prevents nasty feedback loops. If you do want to get the event, then set the This event type will ensure that no information is lost when more events are raised than there is room internally. In that case the struct |
|
|
4 |
Triggered immediately when the reception of a frame has begun. This event has a struct If the hardware needs to be stopped in the case of a buffer underrun it might not be able to generate this event. In such cases the |
|
|
5 |
This event is triggered when a source parameter change is detected during runtime by the video device. It can be a runtime resolution change triggered by a video decoder or the format change happening on an input connector. This event requires that the This event has a struct |
|
|
6 |
Triggered whenever the motion detection state for one or more of the regions changes. This event has a struct |
|
|
0x08000000 |
Base event number for driver-private events. |
v4l2_event_vsync
|
__u8 |
|
The upcoming field. See enum |
v4l2_event_ctrl
|
__u32 |
|
A bitmask that tells what has changed. See ctrl-changes-flags. |
|
__u32 |
|
The type of the control. See enum |
|
union { |
(anonymous) |
|
|
__s32 |
|
The 32-bit value of the control for 32-bit control types. This is 0 for string controls since the value of a string cannot be passed using ioctl VIDIOC_DQEVENT. |
|
__s64 |
|
The 64-bit value of the control for 64-bit control types. |
|
} |
||
|
__u32 |
|
The control flags. See control-flags. |
|
__s32 |
|
The minimum value of the control. See struct v4l2_queryctrl. |
|
__s32 |
|
The maximum value of the control. See struct v4l2_queryctrl. |
|
__s32 |
|
The step value of the control. See struct v4l2_queryctrl. |
|
__s32 |
|
The default value of the control. See struct v4l2_queryctrl. |
v4l2_event_frame_sync
|
__u32 |
|
The sequence number of the frame being received. |
v4l2_event_src_change
|
__u32 |
|
A bitmask that tells what has changed. See src-changes-flags. |
v4l2_event_motion_det
|
__u32 |
|
Currently only one flag is available: if |
|
__u32 |
|
The sequence number of the frame being received. Only valid if the |
|
__u32 |
|
The bitmask of the regions that reported motion. There is at least one region. If this field is 0, then no motion was detected at all. If there is no |
|
|
0x0001 |
This control event was triggered because the value of the control changed. Special cases: Volatile controls do no generate this event; If a control has the |
|
|
0x0002 |
This control event was triggered because the control flags changed. |
|
|
0x0004 |
This control event was triggered because the minimum, maximum, step or the default value of the control changed. |
|
|
0x0008 |
This control event was triggered because the dimensions of the control changed. Note that the number of dimensions remains the same. |
|
|
0x0001 |
This event gets triggered when a resolution change is detected at an input. This can come from an input connector or from a video decoder. Applications will have to query the new resolution (if any, the signal may also have been lost). For stateful decoders follow the guidelines in Memory-to-Memory Stateful Video Decoder Interface. Video Capture devices have to query the new timings using ioctl VIDIOC_QUERY_DV_TIMINGS or VIDIOC_QUERYSTD. Important: even if the new video timings appear identical to the old ones, receiving this event indicates that there was an issue with the video signal and you must stop and restart streaming (VIDIOC_STREAMOFF followed by VIDIOC_STREAMON). The reason is that many Video Capture devices are not able to recover from a temporary loss of signal and so restarting streaming I/O is required in order for the hardware to synchronize to the video signal. |
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.
ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_DV_TIMINGS_CAP - VIDIOC_SUBDEV_DV_TIMINGS_CAP - The capabilities of the Digital Video receiver/transmitter
Synopsis #
int ioctl(int fd, VIDIOC_DV_TIMINGS_CAP, struct v4l2_dv_timings_cap *argp)
int ioctl(int fd, VIDIOC_SUBDEV_DV_TIMINGS_CAP, struct v4l2_dv_timings_cap *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_dv_timings_cap.
Description #
To query the capabilities of the DV receiver/transmitter applications initialize the pad field to 0, zero the reserved array of struct v4l2_dv_timings_cap and call the VIDIOC_DV_TIMINGS_CAP ioctl on a video node and the driver will fill in the structure.
When implemented by the driver DV capabilities of subdevices can be queried by calling the VIDIOC_SUBDEV_DV_TIMINGS_CAP ioctl directly on a subdevice node. The capabilities are specific to inputs (for DV receivers) or outputs (for DV transmitters), applications must specify the desired pad number in the struct v4l2_dv_timings_cap pad field and zero the reserved array. Attempts to query capabilities on a pad that doesn't support them will return an EINVAL error code.
v4l2_bt_timings_cap
|
__u32 |
|
Minimum width of the active video in pixels. |
|
__u32 |
|
Maximum width of the active video in pixels. |
|
__u32 |
|
Minimum height of the active video in lines. |
|
__u32 |
|
Maximum height of the active video in lines. |
|
__u64 |
|
Minimum pixelclock frequency in Hz. |
|
__u64 |
|
Maximum pixelclock frequency in Hz. |
|
__u32 |
|
The video standard(s) supported by the hardware. See dv-bt-standards for a list of standards. |
|
__u32 |
|
Several flags giving more information about the capabilities. See dv-bt-cap-capabilities for a description of the flags. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
v4l2_dv_timings_cap
|
__u32 |
|
Type of DV timings as listed in dv-timing-types. |
|
__u32 |
|
Pad number as reported by the media controller API. This field is only used when operating on a subdevice node. When operating on a video node applications must set this field to zero. |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
union { |
(anonymous) |
|
|
struct |
|
BT.656/1120 timings capabilities of the hardware. |
|
__u32 |
|
|
|
} |
||
|
Flag |
Description |
|
|
Interlaced formats are supported. |
|
|
Progressive formats are supported. |
|
|
CVT/GTF specific: the timings can make use of reduced blanking (CVT) or the 'Secondary GTF' curve (GTF). |
|
|
Can support non-standard timings, i.e. timings not belonging to the standards set in the |
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.
ioctl VIDIOC_ENCODER_CMD, VIDIOC_TRY_ENCODER_CMD
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENCODER_CMD - VIDIOC_TRY_ENCODER_CMD - Execute an encoder command
Synopsis #
int ioctl(int fd, VIDIOC_ENCODER_CMD, struct v4l2_encoder_cmd *argp)
int ioctl(int fd, VIDIOC_TRY_ENCODER_CMD, struct v4l2_encoder_cmd *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_encoder_cmd.
Description #
These ioctls control an audio/video (usually MPEG-) encoder. VIDIOC_ENCODER_CMD sends a command to the encoder, VIDIOC_TRY_ENCODER_CMD can be used to try a command without actually executing it.
To send a command applications must initialize all fields of a struct v4l2_encoder_cmd and call VIDIOC_ENCODER_CMD or VIDIOC_TRY_ENCODER_CMD with a pointer to this structure.
The cmd field must contain the command code. Some commands use the flags field for additional information.
After a STOP command, read() calls will read the remaining data buffered by the driver. When the buffer is empty, read() will return zero and the next read() call will restart the encoder.
A read() or VIDIOC_STREAMON call sends an implicit START command to the encoder if it has not been started yet. Applies to both queues of mem2mem encoders.
A close() or VIDIOC_STREAMOFF call of a streaming file descriptor sends an implicit immediate STOP to the encoder, and all buffered data is discarded. Applies to both queues of mem2mem encoders.
These ioctls are optional, not all drivers may support them. They were introduced in Linux 2.6.21. They are, however, mandatory for stateful mem2mem encoders (as further documented in Memory-to-Memory Stateful Video Encoder Interface).
v4l2_encoder_cmd
|
__u32 |
|
The encoder command, see encoder-cmds. |
|
__u32 |
|
Flags to go with the command, see encoder-flags. If no flags are defined for this command, drivers and applications must set this field to zero. |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
|
0 |
Start the encoder. When the encoder is already running or paused, this command does nothing. No flags are defined for this command. For a device implementing the Memory-to-Memory Stateful Video Encoder Interface, once the drain sequence is initiated with the |
|
|
1 |
Stop the encoder. When the For a device implementing the Memory-to-Memory Stateful Video Encoder Interface, the command will initiate the drain sequence as documented in Memory-to-Memory Stateful Video Encoder Interface. No flags or other arguments are accepted in this case. Any attempt to invoke the command again before the sequence completes will trigger an |
|
|
2 |
Pause the encoder. When the encoder has not been started yet, the driver will return an |
|
|
3 |
Resume encoding after a PAUSE command. When the encoder has not been started yet, the driver will return an |
|
|
0x0001 |
Stop encoding at the end of the current Group Of Pictures, rather than immediately. Does not apply to Memory-to-Memory Stateful Video Encoder Interface. |
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.
-
EBUSY
A drain sequence of a device implementing the Memory-to-Memory Stateful Video Encoder Interface is still in progress. It is not allowed to issue another encoder command until it completes.
-
EINVAL
The
cmdfield is invalid. -
EPERM
The application sent a PAUSE or RESUME command when the encoder was not running.
ioctl VIDIOC_ENUM_DV_TIMINGS, VIDIOC_SUBDEV_ENUM_DV_TIMINGS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUM_DV_TIMINGS - VIDIOC_SUBDEV_ENUM_DV_TIMINGS - Enumerate supported Digital Video timings
Synopsis #
int ioctl(int fd, VIDIOC_ENUM_DV_TIMINGS, struct v4l2_enum_dv_timings *argp)
int ioctl(int fd, VIDIOC_SUBDEV_ENUM_DV_TIMINGS, struct v4l2_enum_dv_timings *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_enum_dv_timings.
Description #
While some DV receivers or transmitters support a wide range of timings, others support only a limited number of timings. With this ioctl applications can enumerate a list of known supported timings. Call ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP to check if it also supports other standards or even custom timings that are not in this list.
To query the available timings, applications initialize the index field, set the pad field to 0, zero the reserved array of struct v4l2_enum_dv_timings and call the VIDIOC_ENUM_DV_TIMINGS ioctl on a video node with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all supported DV timings, applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
When implemented by the driver DV timings of subdevices can be queried by calling the VIDIOC_SUBDEV_ENUM_DV_TIMINGS ioctl directly on a subdevice node. The DV timings are specific to inputs (for DV receivers) or outputs (for DV transmitters), applications must specify the desired pad number in the struct v4l2_enum_dv_timings pad field. Attempts to enumerate timings on a pad that doesn't support them will return an EINVAL error code.
v4l2_enum_dv_timings
|
__u32 |
|
Number of the DV timings, set by the application. |
|
__u32 |
|
Pad number as reported by the media controller API. This field is only used when operating on a subdevice node. When operating on a video node applications must set this field to zero. |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
struct |
|
The timings. |
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.
-
EINVAL
The struct
v4l2_enum_dv_timingsindexis out of bounds or thepadnumber is invalid. -
ENODATA
Digital video presets are not supported for this input or output.
ioctl VIDIOC_ENUM_FMT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUM_FMT - Enumerate image formats
Synopsis #
int ioctl(int fd, VIDIOC_ENUM_FMT, struct v4l2_fmtdesc *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_fmtdesc.
Description #
To enumerate image formats applications initialize the type, mbus_code and index fields of struct v4l2_fmtdesc and call the ioctl VIDIOC_ENUM_FMT ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code. All formats are enumerable by beginning at index zero and incrementing by one until EINVAL is returned. If applicable, drivers shall return formats in preference order, where preferred formats are returned before (that is, with lower index value) less-preferred formats.
Depending on the V4L2_CAP_IO_MC capability, the mbus_code field is handled differently:
-
V4L2_CAP_IO_MCis not set (also known as a 'video-node-centric' driver)Applications shall initialize the
mbus_codefield to zero and drivers shall ignore the value of the field.Drivers shall enumerate all image formats.
-
V4L2_CAP_IO_MCis set (also known as an 'MC-centric' driver)If the
mbus_codefield is zero, then all image formats shall be enumerated.If the
mbus_codefield is initialized to a valid (non-zero) media bus format code, then drivers shall restrict enumeration to only the image formats that can produce (for video output devices) or be produced from (for video capture devices) that media bus code. If thembus_codeis unsupported by the driver, thenEINVALshall be returned.Regardless of the value of the
mbus_codefield, the enumerated image formats shall not depend on the active configuration of the video device or device pipeline.
v4l2_fmtdesc
|
__u32 |
|
Number of the format in the enumeration, set by the application. This is in no way related to the |
|
__u32 |
|
Type of the data stream, set by the application. Only these types are valid here: |
|
__u32 |
|
See fmtdesc-flags |
|
__u8 |
|
Description of the format, a NUL-terminated ASCII string. This information is intended for the user, for example: "YUV 4:2:2". |
|
__u32 |
|
The image format identifier. This is a four character code as computed by the v4l2_fourcc() macro: |
|
Several image formats are already defined by this specification in Image Formats. |
||
|
__u32 |
|
Media bus code restricting the enumerated formats, set by the application. Only applicable to drivers that advertise the |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
|
|
0x0001 |
This is a compressed format. |
|
|
0x0002 |
This format is not native to the device but emulated through software (usually libv4l2), where possible try to use a native format instead for better performance. |
|
|
0x0004 |
The hardware decoder for this compressed bytestream format (aka coded format) is capable of parsing a continuous bytestream. Applications do not need to parse the bytestream themselves to find the boundaries between frames/fields. This flag can only be used in combination with the |
|
|
0x0008 |
Dynamic resolution switching is supported by the device for this compressed bytestream format (aka coded format). It will notify the user via the event This flag can only be used in combination with the |
|
|
0x0010 |
The hardware encoder supports setting the This flag can only be used in combination with the |
|
|
0x0020 |
The driver allows the application to try to change the default colorspace. This flag is relevant only for capture devices. The application can ask to configure the colorspace of the capture device when calling the VIDIOC_S_FMT ioctl with V4L2_PIX_FMT_FLAG_SET_CSC set. |
|
|
0x0040 |
The driver allows the application to try to change the default transfer function. This flag is relevant only for capture devices. The application can ask to configure the transfer function of the capture device when calling the VIDIOC_S_FMT ioctl with V4L2_PIX_FMT_FLAG_SET_CSC set. |
|
|
0x0080 |
The driver allows the application to try to change the default Y'CbCr encoding. This flag is relevant only for capture devices. The application can ask to configure the Y'CbCr encoding of the capture device when calling the VIDIOC_S_FMT ioctl with V4L2_PIX_FMT_FLAG_SET_CSC set. |
|
|
0x0080 |
The driver allows the application to try to change the default HSV encoding. This flag is relevant only for capture devices. The application can ask to configure the HSV encoding of the capture device when calling the VIDIOC_S_FMT ioctl with V4L2_PIX_FMT_FLAG_SET_CSC set. |
|
|
0x0100 |
The driver allows the application to try to change the default quantization. This flag is relevant only for capture devices. The application can ask to configure the quantization of the capture device when calling the VIDIOC_S_FMT ioctl with V4L2_PIX_FMT_FLAG_SET_CSC set. |
|
|
0x0200 |
The metadata format is line-based. In this case the |
|
|
0x80000000 |
When the applications ORs |
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.
-
EINVAL
The struct
v4l2_fmtdesctypeis not supported or theindexis out of bounds.If
V4L2_CAP_IO_MCis set and the specifiedmbus_codeis unsupported, then also return this error code.
ioctl VIDIOC_ENUM_FRAMEINTERVALS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUM_FRAMEINTERVALS - Enumerate frame intervals
Synopsis #
int ioctl(int fd, VIDIOC_ENUM_FRAMEINTERVALS, struct v4l2_frmivalenum *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_frmivalenumthat contains a pixel format and size and receives a frame interval.
Description #
This ioctl allows applications to enumerate all frame intervals that the device supports for the given pixel format and frame size.
The supported pixel formats and frame sizes can be obtained by using the ioctl VIDIOC_ENUM_FMT and ioctl VIDIOC_ENUM_FRAMESIZES functions.
The return value and the content of the v4l2_frmivalenum.type field depend on the type of frame intervals the device supports. Here are the semantics of the function for the different cases:
-
Discrete: The function returns success if the given index value (zero-based) is valid. The application should increase the index by one for each call until
EINVALis returned. Thev4l2_frmivalenum.typefield is set toV4L2_FRMIVAL_TYPE_DISCRETEby the driver. Of the union only thediscretemember is valid. -
Step-wise: The function returns success if the given index value is zero and
EINVALfor any other index value. Thev4l2_frmivalenum.typefield is set toV4L2_FRMIVAL_TYPE_STEPWISEby the driver. Of the union only thestepwisemember is valid. -
Continuous: This is a special case of the step-wise type above. The function returns success if the given index value is zero and
EINVALfor any other index value. Thev4l2_frmivalenum.typefield is set toV4L2_FRMIVAL_TYPE_CONTINUOUSby the driver. Of the union only thestepwisemember is valid and thestepvalue is set to 1.
When the application calls the function with index zero, it must check the type field to determine the type of frame interval enumeration the device supports. Only for the V4L2_FRMIVAL_TYPE_DISCRETE type does it make sense to increase the index value to receive more frame intervals.
Applications can assume that the enumeration data does not change without any interaction from the application itself. This means that the enumeration data is consistent if the application does not perform any other ioctl calls while it runs the frame interval enumeration.
Structs #
In the structs below, IN denotes a value that has to be filled in by the application, OUT denotes values that the driver fills in. The application should zero out all members except for the IN fields.
v4l2_frmival_stepwise
|
struct |
|
Minimum frame interval [s]. |
|
struct |
|
Maximum frame interval [s]. |
|
struct |
|
Frame interval step size [s]. |
v4l2_frmivalenum
|
__u32 |
|
IN: Index of the given frame interval in the enumeration. |
|
__u32 |
|
IN: Pixel format for which the frame intervals are enumerated. |
|
__u32 |
|
IN: Frame width for which the frame intervals are enumerated. |
|
__u32 |
|
IN: Frame height for which the frame intervals are enumerated. |
|
__u32 |
|
OUT: Frame interval type the device supports. |
|
union { |
(anonymous) |
OUT: Frame interval with the given index. |
|
struct |
|
Frame interval [s]. |
|
struct |
|
|
|
} |
||
|
__u32 |
|
Reserved space for future use. Must be zeroed by drivers and applications. |
Enums #
v4l2_frmivaltypes
|
|
1 |
Discrete frame interval. |
|
|
2 |
Continuous frame interval. |
|
|
3 |
Step-wise defined frame interval. |
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.
ioctl VIDIOC_ENUM_FRAMESIZES
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUM_FRAMESIZES - Enumerate frame sizes
Synopsis #
int ioctl(int fd, VIDIOC_ENUM_FRAMESIZES, struct v4l2_frmsizeenum *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_frmsizeenumthat contains an index and pixel format and receives a frame width and height.
Description #
This ioctl allows applications to enumerate all frame sizes (i. e. width and height in pixels) that the device supports for the given pixel format.
The supported pixel formats can be obtained by using the ioctl VIDIOC_ENUM_FMT function.
The return value and the content of the v4l2_frmsizeenum.type field depend on the type of frame sizes the device supports. Here are the semantics of the function for the different cases:
-
Discrete: The function returns success if the given index value (zero-based) is valid. The application should increase the index by one for each call until
EINVALis returned. Thev4l2_frmsizeenum.typefield is set toV4L2_FRMSIZE_TYPE_DISCRETEby the driver. Of the union only thediscretemember is valid. -
Step-wise: The function returns success if the given index value is zero and
EINVALfor any other index value. Thev4l2_frmsizeenum.typefield is set toV4L2_FRMSIZE_TYPE_STEPWISEby the driver. Of the union only thestepwisemember is valid. -
Continuous: This is a special case of the step-wise type above. The function returns success if the given index value is zero and
EINVALfor any other index value. Thev4l2_frmsizeenum.typefield is set toV4L2_FRMSIZE_TYPE_CONTINUOUSby the driver. Of the union only thestepwisemember is valid and thestep_widthandstep_heightvalues are set to 1.
When the application calls the function with index zero, it must check the type field to determine the type of frame size enumeration the device supports. Only for the V4L2_FRMSIZE_TYPE_DISCRETE type does it make sense to increase the index value to receive more frame sizes.
Applications can assume that the enumeration data does not change without any interaction from the application itself. This means that the enumeration data is consistent if the application does not perform any other ioctl calls while it runs the frame size enumeration.
Structs #
In the structs below, IN denotes a value that has to be filled in by the application, OUT denotes values that the driver fills in. The application should zero out all members except for the IN fields.
v4l2_frmsize_discrete
|
__u32 |
|
Width of the frame [pixel]. |
|
__u32 |
|
Height of the frame [pixel]. |
v4l2_frmsize_stepwise
|
__u32 |
|
Minimum frame width [pixel]. |
|
__u32 |
|
Maximum frame width [pixel]. |
|
__u32 |
|
Frame width step size [pixel]. |
|
__u32 |
|
Minimum frame height [pixel]. |
|
__u32 |
|
Maximum frame height [pixel]. |
|
__u32 |
|
Frame height step size [pixel]. |
v4l2_frmsizeenum
|
__u32 |
|
IN: Index of the given frame size in the enumeration. |
|
__u32 |
|
IN: Pixel format for which the frame sizes are enumerated. |
|
__u32 |
|
OUT: Frame size type the device supports. |
|
union { |
(anonymous) |
OUT: Frame size with the given index. |
|
struct |
|
|
|
struct |
|
|
|
} |
||
|
__u32 |
|
Reserved space for future use. Must be zeroed by drivers and applications. |
Enums #
v4l2_frmsizetypes
|
|
1 |
Discrete frame size. |
|
|
2 |
Continuous frame size. |
|
|
3 |
Step-wise defined frame size. |
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.
ioctl VIDIOC_ENUM_FREQ_BANDS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUM_FREQ_BANDS - Enumerate supported frequency bands
Synopsis #
int ioctl(int fd, VIDIOC_ENUM_FREQ_BANDS, struct v4l2_frequency_band *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_frequency_band.
Description #
Enumerates the frequency bands that a tuner or modulator supports. To do this applications initialize the tuner, type and index fields, and zero out the reserved array of a struct v4l2_frequency_band and call the ioctl VIDIOC_ENUM_FREQ_BANDS ioctl with a pointer to this structure.
This ioctl is supported if the V4L2_TUNER_CAP_FREQ_BANDS capability of the corresponding tuner/modulator is set.
v4l2_frequency_band
|
__u32 |
|
The tuner or modulator index number. This is the same value as in the struct |
||
|
__u32 |
|
The tuner type. This is the same value as in the struct |
||
|
__u32 |
|
Identifies the frequency band, set by the application. |
||
|
__u32 |
|
The tuner/modulator capability flags for this frequency band, see tuner-capability. The |
||
|
__u32 |
|
The lowest tunable frequency in units of 62.5 kHz, or if the |
||
|
__u32 |
|
The highest tunable frequency in units of 62.5 kHz, or if the |
||
|
__u32 |
|
The supported modulation systems of this frequency band. See band-modulation. |
||
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
||
|
|
0x02 |
Vestigial Sideband modulation, used for analog TV. |
|
|
0x04 |
Frequency Modulation, commonly used for analog radio. |
|
|
0x08 |
Amplitude Modulation, commonly used for analog radio. |
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.
-
EINVAL
The
tunerorindexis out of bounds or thetypefield is wrong.
ioctl VIDIOC_ENUMAUDIO
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUMAUDIO - Enumerate audio inputs
Synopsis #
int ioctl(int fd, VIDIOC_ENUMAUDIO, struct v4l2_audio *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_audio.
Description #
To query the attributes of an audio input applications initialize the index field and zero out the reserved array of a struct v4l2_audio and call the ioctl VIDIOC_ENUMAUDIO ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all audio inputs applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
See VIDIOC_G_AUDIO for a description of struct v4l2_audio.
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.
-
EINVAL
The number of the audio input is out of bounds.
ioctl VIDIOC_ENUMAUDOUT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUMAUDOUT - Enumerate audio outputs
Synopsis #
int ioctl(int fd, VIDIOC_ENUMAUDOUT, struct v4l2_audioout *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_audioout.
Description #
To query the attributes of an audio output applications initialize the index field and zero out the reserved array of a struct v4l2_audioout and call the VIDIOC_G_AUDOUT ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all audio outputs applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
See VIDIOC_G_AUDIOout for a description of struct v4l2_audioout.
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.
-
EINVAL
The number of the audio output is out of bounds.
ioctl VIDIOC_ENUMINPUT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUMINPUT - Enumerate video inputs
Synopsis #
int ioctl(int fd, VIDIOC_ENUMINPUT, struct v4l2_input *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_input.
Description #
To query the attributes of a video input applications initialize the index field of struct v4l2_input and call the ioctl VIDIOC_ENUMINPUT with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all inputs applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
v4l2_input
|
__u32 |
|
Identifies the input, set by the application. |
|
__u8 |
|
Name of the video input, a NUL-terminated ASCII string, for example: "Vin (Composite 2)". This information is intended for the user, preferably the connector label on the device itself. |
|
__u32 |
|
Type of the input, see input-type. |
|
__u32 |
|
Drivers can enumerate up to 32 video and audio inputs. This field shows which audio inputs were selectable as audio source if this was the currently selected video input. It is a bit mask. The LSB corresponds to audio input 0, the MSB to input 31. Any number of bits can be set, or none. When the driver does not enumerate audio inputs no bits must be set. Applications shall not interpret this as lack of audio support. Some drivers automatically select audio sources and do not enumerate them since there is no choice anyway. For details on audio inputs and how to select the current input see Audio Inputs and Outputs. |
|
__u32 |
|
Capture devices can have zero or more tuners (RF demodulators). When the |
|
|
Every video input supports one or more different video standards. This field is a set of all supported standards. For details on video standards and how to switch see Video Standards. |
|
|
__u32 |
|
This field provides status information about the input. See input-status for flags. With the exception of the sensor orientation bits |
|
__u32 |
|
This field provides capabilities for the input. See input-capabilities for flags. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
|
|
1 |
This input uses a tuner (RF demodulator). |
|
|
2 |
Any non-tuner video input, for example Composite Video, S-Video, HDMI, camera sensor. The naming as |
|
|
3 |
This input is a touch device for capturing raw touch data. |
|
General |
||
|
|
0x00000001 |
Attached device is off. |
|
|
0x00000002 |
|
|
|
0x00000004 |
The hardware supports color decoding, but does not detect color modulation in the signal. |
|
Sensor Orientation |
||
|
|
0x00000010 |
The input is connected to a device that produces a signal that is flipped horizontally and does not correct this before passing the signal to userspace. |
|
|
0x00000020 |
The input is connected to a device that produces a signal that is flipped vertically and does not correct this before passing the signal to userspace. .. note:: A 180 degree rotation is the same as HFLIP | VFLIP |
|
Analog Video |
||
|
|
0x00000100 |
No horizontal sync lock. |
|
|
0x00000200 |
A color killer circuit automatically disables color decoding when it detects no color modulation. When this flag is set the color killer is enabled and has shut off color decoding. |
|
|
0x00000400 |
No vertical sync lock. |
|
|
0x00000800 |
No standard format lock in case of auto-detection format by the component. |
|
Digital Video |
||
|
|
0x00010000 |
No synchronization lock. |
|
|
0x00020000 |
No equalizer lock. |
|
|
0x00040000 |
Carrier recovery failed. |
|
VCR and Set-Top Box |
||
|
|
0x01000000 |
Macrovision is an analog copy prevention system mangling the video signal to confuse video recorders. When this flag is set Macrovision has been detected. |
|
|
0x02000000 |
Conditional access denied. |
|
|
0x04000000 |
VTR time constant. [?] |
|
|
0x00000002 |
This input supports setting video timings by using |
|
|
0x00000004 |
This input supports setting the TV standard by using |
|
|
0x00000008 |
This input supports setting the native size using the |
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.
-
EINVAL
The struct
v4l2_inputindexis out of bounds.
ioctl VIDIOC_ENUMOUTPUT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUMOUTPUT - Enumerate video outputs
Synopsis #
int ioctl(int fd, VIDIOC_ENUMOUTPUT, struct v4l2_output *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_output.
Description #
To query the attributes of a video outputs applications initialize the index field of struct v4l2_output and call the ioctl VIDIOC_ENUMOUTPUT with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all outputs applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
v4l2_output
|
__u32 |
|
Identifies the output, set by the application. |
|
__u8 |
|
Name of the video output, a NUL-terminated ASCII string, for example: "Vout". This information is intended for the user, preferably the connector label on the device itself. |
|
__u32 |
|
Type of the output, see output-type. |
|
__u32 |
|
Drivers can enumerate up to 32 video and audio outputs. This field shows which audio outputs were selectable as the current output if this was the currently selected video output. It is a bit mask. The LSB corresponds to audio output 0, the MSB to output 31. Any number of bits can be set, or none. When the driver does not enumerate audio outputs no bits must be set. Applications shall not interpret this as lack of audio support. Drivers may automatically select audio outputs without enumerating them. For details on audio outputs and how to select the current output see Audio Inputs and Outputs. |
|
__u32 |
|
Output devices can have zero or more RF modulators. When the |
|
|
Every video output supports one or more different video standards. This field is a set of all supported standards. For details on video standards and how to switch see Video Standards. |
|
|
__u32 |
|
This field provides capabilities for the output. See output-capabilities for flags. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
|
|
1 |
This output is an analog TV modulator. |
|
|
2 |
Any non-modulator video output, for example Composite Video, S-Video, HDMI. The naming as |
|
|
3 |
The video output will be copied to a video overlay. |
|
|
0x00000002 |
This output supports setting video timings by using |
|
|
0x00000004 |
This output supports setting the TV standard by using |
|
|
0x00000008 |
This output supports setting the native size using the |
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.
-
EINVAL
The struct
v4l2_outputindexis out of bounds.
ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_ENUMSTD - VIDIOC_SUBDEV_ENUMSTD - Enumerate supported video standards
Synopsis #
int ioctl(int fd, VIDIOC_ENUMSTD, struct v4l2_standard *argp)
int ioctl(int fd, VIDIOC_SUBDEV_ENUMSTD, struct v4l2_standard *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_standard.
Description #
To query the attributes of a video standard, especially a custom (driver defined) one, applications initialize the index field of struct v4l2_standard and call the ioctl VIDIOC_ENUMSTD, VIDIOC_SUBDEV_ENUMSTD ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all standards applications shall begin at index zero, incrementing by one until the driver returns EINVAL. Drivers may enumerate a different set of standards after switching the video input or output. 1
v4l2_standard
|
__u32 |
|
Number of the video standard, set by the application. |
|
|
The bits in this field identify the standard as one of the common standards listed in v4l2-std-id, or if bits 32 to 63 are set as custom standards. Multiple bits can be set if the hardware does not distinguish between these standards, however separate indices do not indicate the opposite. The |
|
|
__u8 |
|
Name of the standard, a NUL-terminated ASCII string, for example: "PAL-B/G", "NTSC Japan". This information is intended for the user. |
|
struct |
|
The frame period (not field period) is numerator / denominator. For example M/NTSC has a frame period of 1001 / 30000 seconds. |
|
__u32 |
|
Total lines per frame including blanking, e. g. 625 for B/PAL. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
v4l2_fract
|
__u32 |
|
|
|
__u32 |
|
|
__u64 |
|
This type is a set, each bit representing another video standard as listed below and in video-standards. The 32 most significant bits are reserved for custom (driver defined) video standards. |
V4L2_STD_PAL_60 is a hybrid standard with 525 lines, 60 Hz refresh rate, and PAL color modulation with a 4.43 MHz color subcarrier. Some PAL video recorders can play back NTSC tapes in this mode for display on a 50/60 Hz agnostic PAL TV.
V4L2_STD_NTSC_443 is a hybrid standard with 525 lines, 60 Hz refresh rate, and NTSC color modulation with a 4.43 MHz color subcarrier.
/* ATSC/HDTV */
V4L2_STD_ATSC_8_VSB and V4L2_STD_ATSC_16_VSB are U.S. terrestrial digital TV standards. Presently the V4L2 API does not support digital TV. See also the Linux DVB API at https://linuxtv.org.
|
Characteristics |
M/NTSC 2 |
M/PAL |
N/PAL 3 |
B, B1, G/PAL |
D, D1, K/PAL |
H/PAL |
I/PAL |
B, G/SECAM |
D, K/SECAM |
K1/SECAM |
L/SECAM |
|---|---|---|---|---|---|---|---|---|---|---|---|
|
Frame lines |
525 |
625 |
|||||||||
|
Frame period (s) |
1001/30000 |
1/25 |
|||||||||
|
Chrominance sub-carrier frequency (Hz) |
3579545 ± 10 |
3579611.49 ± 10 |
4433618.75 ± 5 (3582056.25 ± 5) |
4433618.75 ± 5 |
4433618.75 ± 1 |
fOR = 4406250 ± 2000, fOB = 4250000 ± 2000 |
|||||
|
Nominal radio-frequency channel bandwidth (MHz) |
6 |
6 |
6 |
B: 7; B1, G: 8 |
8 |
8 |
8 |
8 |
8 |
8 |
8 |
|
Sound carrier relative to vision carrier (MHz) |
4.5 |
4.5 |
4.5 |
6.5 ± 0.001 |
5.5 |
5.9996 ± 0.0005 |
5.5 ± 0.001 |
6.5 ± 0.001 |
6.5 |
6.5 8 |
|
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.
-
EINVAL
The struct
v4l2_standardindexis out of bounds. -
ENODATA
Standard video timings are not supported for this input or output.
[1] The supported standards may overlap and we need an unambiguous set to find the current standard returned by VIDIOC_G_STD.
[2] Japan uses a standard similar to M/NTSC (V4L2_STD_NTSC_M_JP).
[3] The values in brackets apply to the combination N/PAL a.k.a. NC used in Argentina (V4L2_STD_PAL_Nc).
[4] In the Federal Republic of Germany, Austria, Italy, the Netherlands, Slovakia and Switzerland a system of two sound carriers is used, the frequency of the second carrier being 242.1875 kHz above the frequency of the first sound carrier. For stereophonic sound transmissions a similar system is used in Australia.
[5] New Zealand uses a sound carrier displaced 5.4996 ± 0.0005 MHz from the vision carrier.
[6] In Denmark, Finland, New Zealand, Sweden and Spain a system of two sound carriers is used. In Iceland, Norway and Poland the same system is being introduced. The second carrier is 5.85 MHz above the vision carrier and is DQPSK modulated with 728 kbit/s sound and data multiplex. (NICAM system)
[7] In the United Kingdom, a system of two sound carriers is used. The second sound carrier is 6.552 MHz above the vision carrier and is DQPSK modulated with a 728 kbit/s sound and data multiplex able to carry two sound channels. (NICAM system)
[8] In France, a digital carrier 5.85 MHz away from the vision carrier may be used in addition to the main sound carrier. It is modulated in differentially encoded QPSK with a 728 kbit/s sound and data multiplexer capable of carrying two sound channels. (NICAM system)
ioctl VIDIOC_EXPBUF
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_EXPBUF - Export a buffer as a DMABUF file descriptor.
Synopsis #
int ioctl(int fd, VIDIOC_EXPBUF, struct v4l2_exportbuffer *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_exportbuffer.
Description #
This ioctl is an extension to the memory mapping I/O method, therefore it is available only for V4L2_MEMORY_MMAP buffers. It can be used to export a buffer as a DMABUF file at any time after buffers have been allocated with the vidioc_reqbufs ioctl.
To export a buffer, applications fill struct v4l2_exportbuffer. The type field is set to the same buffer type as was previously used with struct v4l2_requestbuffers type. Applications must also set the index field. Valid index numbers range from zero to the number of buffers allocated with vidioc_reqbufs (struct v4l2_requestbuffers count) minus one. For the multi-planar API, applications set the plane field to the index of the plane to be exported. Valid planes range from zero to the maximal number of valid planes for the currently active format. For the single-planar API, applications must set plane to zero. Additional flags may be posted in the flags field. Refer to a manual for open() for details. Currently only O_CLOEXEC, O_RDONLY, O_WRONLY, and O_RDWR are supported. All other fields must be set to zero. In the case of multi-planar API, every plane is exported separately using multiple ioctl VIDIOC_EXPBUF calls.
After calling ioctl VIDIOC_EXPBUF the fd field will be set by a driver. This is a DMABUF file descriptor. The application may pass it to other DMABUF-aware devices. Refer to DMABUF importing for details about importing DMABUF files into V4L2 nodes. It is recommended to close a DMABUF file when it is no longer used to allow the associated memory to be reclaimed.
Examples #
int
int
v4l2_exportbuffer
|
__u32 |
|
Type of the buffer, same as struct |
|
__u32 |
|
Number of the buffer, set by the application. This field is only used for memory mapping I/O and can range from zero to the number of buffers allocated with the vidioc_reqbufs and/or ioctl VIDIOC_CREATE_BUFS ioctls. |
|
__u32 |
|
Index of the plane to be exported when using the multi-planar API. Otherwise this value must be set to zero. |
|
__u32 |
|
Flags for the newly created file, currently only |
|
__s32 |
|
The DMABUF file descriptor associated with a buffer. Set by the driver. |
|
__u32 |
|
Reserved field for future use. Drivers and applications must set the array to zero. |
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.
-
EINVAL
A queue is not in MMAP mode or DMABUF exporting is not supported or
flagsortypeorindexorplanefields are invalid.
ioctl VIDIOC_G_AUDIO, VIDIOC_S_AUDIO
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_AUDIO - VIDIOC_S_AUDIO - Query or select the current audio input and its attributes
Synopsis #
int ioctl(int fd, VIDIOC_G_AUDIO, struct v4l2_audio *argp)
int ioctl(int fd, VIDIOC_S_AUDIO, const struct v4l2_audio *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_audio.
Description #
To query the current audio input applications zero out the reserved array of a struct v4l2_audio and call the VIDIOC_G_AUDIO ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the device has no audio inputs, or none which combine with the current video input.
Audio inputs have one writable property, the audio mode. To select the current audio input and change the audio mode, applications initialize the index and mode fields, and the reserved array of a struct v4l2_audio structure and call the VIDIOC_S_AUDIO ioctl. Drivers may switch to a different audio mode if the request cannot be satisfied. However, this is a write-only ioctl, it does not return the actual new audio mode.
v4l2_audio
|
__u32 |
|
Identifies the audio input, set by the driver or application. |
|
__u8 |
|
Name of the audio input, a NUL-terminated ASCII string, for example: "Line In". This information is intended for the user, preferably the connector label on the device itself. |
|
__u32 |
|
Audio capability flags, see audio-capability. |
|
__u32 |
|
Audio mode flags set by drivers and applications (on VIDIOC_S_AUDIO ioctl), see audio-mode. |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
|
0x00001 |
This is a stereo input. The flag is intended to automatically disable stereo recording etc. when the signal is always monaural. The API provides no means to detect if stereo is received, unless the audio input belongs to a tuner. |
|
|
0x00002 |
Automatic Volume Level mode is supported. |
|
|
0x00001 |
AVL mode is on. |
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.
-
EINVAL
No audio inputs combine with the current video input, or the number of the selected audio input is out of bounds or it does not combine.
ioctl VIDIOC_G_AUDOUT, VIDIOC_S_AUDOUT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_AUDOUT - VIDIOC_S_AUDOUT - Query or select the current audio output
Synopsis #
int ioctl(int fd, VIDIOC_G_AUDOUT, struct v4l2_audioout *argp)
int ioctl(int fd, VIDIOC_S_AUDOUT, const struct v4l2_audioout *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_audioout.
Description #
To query the current audio output applications zero out the reserved array of a struct v4l2_audioout and call the VIDIOC_G_AUDOUT ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the device has no audio inputs, or none which combine with the current video output.
Audio outputs have no writable properties. Nevertheless, to select the current audio output applications can initialize the index field and reserved array (which in the future may contain writable properties) of a struct v4l2_audioout structure and call the VIDIOC_S_AUDOUT ioctl. Drivers switch to the requested output or return the EINVAL error code when the index is out of bounds. This is a write-only ioctl, it does not return the current audio output attributes as VIDIOC_G_AUDOUT does.
v4l2_audioout
|
__u32 |
|
Identifies the audio output, set by the driver or application. |
|
__u8 |
|
Name of the audio output, a NUL-terminated ASCII string, for example: "Line Out". This information is intended for the user, preferably the connector label on the device itself. |
|
__u32 |
|
Audio capability flags, none defined yet. Drivers must set this field to zero. |
|
__u32 |
|
Audio mode, none defined yet. Drivers and applications (on |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
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.
-
EINVAL
No audio outputs combine with the current video output, or the number of the selected audio output is out of bounds or it does not combine.
ioctl VIDIOC_G_CROP, VIDIOC_S_CROP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_CROP - VIDIOC_S_CROP - Get or set the current cropping rectangle
Synopsis #
int ioctl(int fd, VIDIOC_G_CROP, struct v4l2_crop *argp)
int ioctl(int fd, VIDIOC_S_CROP, const struct v4l2_crop *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_crop.
Description #
To query the cropping rectangle size and position applications set the type field of a struct v4l2_crop structure to the respective buffer (stream) type and call the VIDIOC_G_CROP ioctl with a pointer to this structure. The driver fills the rest of the structure or returns the EINVAL error code if cropping is not supported.
To change the cropping rectangle applications initialize the type and struct v4l2_rect substructure named c of a v4l2_crop structure and call the VIDIOC_S_CROP ioctl with a pointer to this structure.
The driver first adjusts the requested dimensions against hardware limits, i. e. the bounds given by the capture/output window, and it rounds to the closest possible values of horizontal and vertical offset, width and height. In particular the driver must round the vertical offset of the cropping rectangle to frame lines modulo two, such that the field order cannot be confused.
Second the driver adjusts the image size (the opposite rectangle of the scaling process, source or target depending on the data direction) to the closest size possible while maintaining the current horizontal and vertical scaling factor.
Finally the driver programs the hardware with the actual cropping and image parameters. VIDIOC_S_CROP is a write-only ioctl, it does not return the actual parameters. To query them applications must call VIDIOC_G_CROP and ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT. When the parameters are unsuitable the application may modify the cropping or image parameters and repeat the cycle until satisfactory parameters have been negotiated.
When cropping is not supported then no parameters are changed and VIDIOC_S_CROP returns the EINVAL error code.
v4l2_crop
|
__u32 |
|
Type of the data stream, set by the application. Only these types are valid here: |
|
struct |
|
Cropping rectangle. The same co-ordinate system as for struct |
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.
-
ENODATA
Cropping is not supported for this input or output.
ioctl VIDIOC_G_CTRL, VIDIOC_S_CTRL
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_CTRL - VIDIOC_S_CTRL - Get or set the value of a control
Synopsis #
int ioctl(int fd, VIDIOC_G_CTRL, struct v4l2_control *argp)
int ioctl(int fd, VIDIOC_S_CTRL, struct v4l2_control *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_control.
Description #
To get the current value of a control applications initialize the id field of a struct v4l2_control and call the VIDIOC_G_CTRL ioctl with a pointer to this structure. To change the value of a control applications initialize the id and value fields of a struct v4l2_control and call the VIDIOC_S_CTRL ioctl.
When the id is invalid drivers return an EINVAL error code. When the value is out of bounds drivers can choose to take the closest valid value or return an ERANGE error code, whatever seems more appropriate. However, VIDIOC_S_CTRL is a write-only ioctl, it does not return the actual new value. If the value is inappropriate for the control (e.g. if it refers to an unsupported menu index of a menu control), then EINVAL error code is returned as well.
These ioctls work only with user controls. For other control classes the VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS or VIDIOC_TRY_EXT_CTRLS must be used.
v4l2_control
|
__u32 |
|
Identifies the control, set by the application. |
|
__s32 |
|
New value or current value. |
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.
-
EINVAL
The struct
v4l2_controlidis invalid or thevalueis inappropriate for the given control (i.e. if a menu item is selected that is not supported by the driver according to VIDIOC_QUERYMENU). -
ERANGE
The struct
v4l2_controlvalueis out of bounds. -
EBUSY
The control is temporarily not changeable, possibly because another applications took over control of the device function this control belongs to.
-
EACCES
Attempt to set a read-only control or to get a write-only control.
Or if there is an attempt to set an inactive control and the driver is not capable of caching the new value until the control is active again.
ioctl VIDIOC_G_DV_TIMINGS, VIDIOC_S_DV_TIMINGS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_DV_TIMINGS - VIDIOC_S_DV_TIMINGS - VIDIOC_SUBDEV_G_DV_TIMINGS - VIDIOC_SUBDEV_S_DV_TIMINGS - Get or set DV timings for input or output
Synopsis #
int ioctl(int fd, VIDIOC_G_DV_TIMINGS, struct v4l2_dv_timings *argp)
int ioctl(int fd, VIDIOC_S_DV_TIMINGS, struct v4l2_dv_timings *argp)
int ioctl(int fd, VIDIOC_SUBDEV_G_DV_TIMINGS, struct v4l2_dv_timings *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_DV_TIMINGS, struct v4l2_dv_timings *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_dv_timings.
Description #
To set DV timings for the input or output, applications use the VIDIOC_S_DV_TIMINGS ioctl and to get the current timings, applications use the VIDIOC_G_DV_TIMINGS ioctl. The detailed timing information is filled in using the structure struct v4l2_dv_timings. These ioctls take a pointer to the struct v4l2_dv_timings structure as argument. If the ioctl is not supported or the timing values are not correct, the driver returns EINVAL error code.
Calling VIDIOC_SUBDEV_S_DV_TIMINGS on a subdev device node that has been registered in read-only mode is not allowed. An error is returned and the errno variable is set to -EPERM.
The linux/v4l2-dv-timings.h header can be used to get the timings of the formats in the CEA-861-E and VESA DMT standards. If the current input or output does not support DV timings (e.g. if ioctl VIDIOC_ENUMINPUT does not set the V4L2_IN_CAP_DV_TIMINGS flag), then ENODATA error code is returned.
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.
-
EINVAL
This ioctl is not supported, or the VIDIOC_S_DV_TIMINGS parameter was unsuitable.
-
ENODATA
Digital video timings are not supported for this input or output.
-
EBUSY
The device is busy and therefore can not change the timings.
-
EPERM
VIDIOC_SUBDEV_S_DV_TIMINGShas been called on a read-only subdevice.
v4l2_bt_timings
|
__u32 |
|
Width of the active video in pixels. |
|
__u32 |
|
Height of the active video frame in lines. So for interlaced formats the height of the active video in each field is |
|
__u32 |
|
Progressive ( |
|
__u32 |
|
This is a bit mask that defines polarities of sync signals. bit 0 ( |
|
__u64 |
|
Pixel clock in Hz. Ex. 74.25MHz->74250000 |
|
__u32 |
|
Horizontal front porch in pixels |
|
__u32 |
|
Horizontal sync length in pixels |
|
__u32 |
|
Horizontal back porch in pixels |
|
__u32 |
|
Vertical front porch in lines. For interlaced formats this refers to the odd field (aka field 1). |
|
__u32 |
|
Vertical sync length in lines. For interlaced formats this refers to the odd field (aka field 1). |
|
__u32 |
|
Vertical back porch in lines. For interlaced formats this refers to the odd field (aka field 1). |
|
__u32 |
|
Vertical front porch in lines for the even field (aka field 2) of interlaced field formats. Must be 0 for progressive formats. |
|
__u32 |
|
Vertical sync length in lines for the even field (aka field 2) of interlaced field formats. Must be 0 for progressive formats. |
|
__u32 |
|
Vertical back porch in lines for the even field (aka field 2) of interlaced field formats. Must be 0 for progressive formats. |
|
__u32 |
|
The video standard(s) this format belongs to. This will be filled in by the driver. Applications must set this to 0. See dv-bt-standards for a list of standards. |
|
__u32 |
|
Several flags giving more information about the format. See dv-bt-flags for a description of the flags. |
|
struct |
|
The picture aspect if the pixels are not square. Only valid if the |
|
__u8 |
|
The Video Identification Code according to the CEA-861 standard. Only valid if the |
|
__u8 |
|
The Video Identification Code according to the HDMI standard. Only valid if the |
|
__u8 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
v4l2_dv_timings
|
__u32 |
|
Type of DV timings as listed in dv-timing-types. |
|
union { |
(anonymous) |
|
|
struct |
|
Timings defined by BT.656/1120 specifications |
|
__u32 |
|
|
|
} |
||
|
Timing type |
value |
Description |
|
|
0 |
BT.656/1120 timings |
|
Timing standard |
Description |
|
|
The timings follow the CEA-861 Digital TV Profile standard |
|
|
The timings follow the VESA Discrete Monitor Timings standard |
|
|
The timings follow the VESA Coordinated Video Timings standard |
|
|
The timings follow the VESA Generalized Timings Formula standard |
|
|
The timings follow the SDI Timings standard. There are no horizontal syncs/porches at all in this format. Total blanking timings must be set in hsync or vsync fields only. |
|
Flag |
Description |
|
|
CVT/GTF specific: the timings use reduced blanking (CVT) or the 'Secondary GTF' curve (GTF). In both cases the horizontal and/or vertical blanking intervals are reduced, allowing a higher resolution over the same bandwidth. This is a read-only flag, applications must not set this. |
|
|
CEA-861 specific: set for CEA-861 formats with a framerate that is a multiple of six. These formats can be optionally played at 1 / 1.001 speed to be compatible with 60 Hz based standards such as NTSC and PAL-M that use a framerate of 29.97 frames per second. If the transmitter can't generate such frequencies, then the flag will also be cleared. This is a read-only flag, applications must not set this. |
|
|
CEA-861 specific: only valid for video transmitters or video receivers that have the If the application sets this flag for a transmitter, then the pixelclock used to set up the transmitter is divided by 1.001 to make it compatible with NTSC framerates. If the transmitter can't generate such frequencies, then the flag will be cleared. If a video receiver detects that the format uses a reduced framerate, then it will set this flag to signal this to the application. |
|
|
Specific to interlaced formats: if set, then the vertical frontporch of field 1 (aka the odd field) is really one half-line longer and the vertical backporch of field 2 (aka the even field) is really one half-line shorter, so each field has exactly the same number of half-lines. Whether half-lines can be detected or used depends on the hardware. |
|
|
If set, then this is a Consumer Electronics (CE) video format. Such formats differ from other formats (commonly called IT formats) in that if R'G'B' encoding is used then by default the R'G'B' values use limited range (i.e. 16-235) as opposed to full range (i.e. 0-255). All formats defined in CEA-861 except for the 640x480p59.94 format are CE formats. |
|
|
Some formats like SMPTE-125M have an interlaced signal with a odd total height. For these formats, if this flag is set, the first field has the extra line. Else, it is the second field. |
|
|
If set, then the picture_aspect field is valid. Otherwise assume that the pixels are square, so the picture aspect ratio is the same as the width to height ratio. |
|
|
If set, then the cea861_vic field is valid and contains the Video Identification Code as per the CEA-861 standard. |
|
|
If set, then the hdmi_vic field is valid and contains the Video Identification Code as per the HDMI standard (HDMI Vendor Specific InfoFrame). |
|
|
CEA-861 specific: only valid for video receivers, the flag is cleared by transmitters. If set, then the hardware can detect the difference between regular framerates and framerates reduced by 1000/1001. E.g.: 60 vs 59.94 Hz, 30 vs 29.97 Hz or 24 vs 23.976 Hz. |
ioctl VIDIOC_G_EDID, VIDIOC_S_EDID, VIDIOC_SUBDEV_G_EDID, VIDIOC_SUBDEV_S_EDID
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_EDID - VIDIOC_S_EDID - VIDIOC_SUBDEV_G_EDID - VIDIOC_SUBDEV_S_EDID - Get or set the EDID of a video receiver/transmitter
Synopsis #
int ioctl(int fd, VIDIOC_G_EDID, struct v4l2_edid *argp)
int ioctl(int fd, VIDIOC_S_EDID, struct v4l2_edid *argp)
int ioctl(int fd, VIDIOC_SUBDEV_G_EDID, struct v4l2_edid *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_EDID, struct v4l2_edid *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_edid.
Description #
These ioctls can be used to get or set an EDID associated with an input from a receiver or an output of a transmitter device. They can be used with subdevice nodes (/dev/v4l-subdevX) or with video nodes (/dev/videoX).
When used with video nodes the pad field represents the input (for video capture devices) or output (for video output devices) index as is returned by ioctl VIDIOC_ENUMINPUT and ioctl VIDIOC_ENUMOUTPUT respectively. When used with subdevice nodes the pad field represents the input or output pad of the subdevice. If there is no EDID support for the given pad value, then the EINVAL error code will be returned.
To get the EDID data the application has to fill in the pad, start_block, blocks and edid fields, zero the reserved array and call VIDIOC_G_EDID. The current EDID from block start_block and of size blocks will be placed in the memory edid points to. The edid pointer must point to memory at least blocks * 128 bytes large (the size of one block is 128 bytes).
If there are fewer blocks than specified, then the driver will set blocks to the actual number of blocks. If there are no EDID blocks available at all, then the error code ENODATA is set.
If blocks have to be retrieved from the sink, then this call will block until they have been read.
If start_block and blocks are both set to 0 when VIDIOC_G_EDID is called, then the driver will set blocks to the total number of available EDID blocks and it will return 0 without copying any data. This is an easy way to discover how many EDID blocks there are.
To set the EDID blocks of a receiver the application has to fill in the pad, blocks and edid fields, set start_block to 0 and zero the reserved array. It is not possible to set part of an EDID, it is always all or nothing. Setting the EDID data is only valid for receivers as it makes no sense for a transmitter.
The driver assumes that the full EDID is passed in. If there are more EDID blocks than the hardware can handle then the EDID is not written, but instead the error code E2BIG is set and blocks is set to the maximum that the hardware supports. If start_block is any value other than 0 then the error code EINVAL is set.
To disable an EDID you set blocks to 0. Depending on the hardware this will drive the hotplug pin low and/or block the source from reading the EDID data in some way. In any case, the end result is the same: the EDID is no longer available.
v4l2_edid
|
__u32 |
|
Pad for which to get/set the EDID blocks. When used with a video device node the pad represents the input or output index as returned by ioctl VIDIOC_ENUMINPUT and ioctl VIDIOC_ENUMOUTPUT respectively. |
|
__u32 |
|
Read the EDID from starting with this block. Must be 0 when setting the EDID. |
|
__u32 |
|
The number of blocks to get or set. Must be less or equal to 256 (the maximum number of blocks as defined by the standard). When you set the EDID and |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
|
__u8 * |
|
Pointer to memory that contains the EDID. The minimum size is |
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.
-
ENODATAThe EDID data is not available.
-
E2BIGThe EDID data you provided is more than the hardware can handle.
ioctl VIDIOC_G_ENC_INDEX
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_ENC_INDEX - Get meta data about a compressed video stream
Synopsis #
int ioctl(int fd, VIDIOC_G_ENC_INDEX, struct v4l2_enc_idx *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_enc_idx.
Description #
The VIDIOC_G_ENC_INDEX ioctl provides meta data about a compressed video stream the same or another application currently reads from the driver, which is useful for random access into the stream without decoding it.
To read the data applications must call VIDIOC_G_ENC_INDEX with a pointer to a struct v4l2_enc_idx. On success the driver fills the entry array, stores the number of elements written in the entries field, and initializes the entries_cap field.
Each element of the entry array contains meta data about one picture. A VIDIOC_G_ENC_INDEX call reads up to V4L2_ENC_IDX_ENTRIES entries from a driver buffer, which can hold up to entries_cap entries. This number can be lower or higher than V4L2_ENC_IDX_ENTRIES, but not zero. When the application fails to read the meta data in time the oldest entries will be lost. When the buffer is empty or no capturing/encoding is in progress, entries will be zero.
Currently this ioctl is only defined for MPEG-2 program streams and video elementary streams.
v4l2_enc_idx
|
__u32 |
|
The number of entries the driver stored in the |
|
__u32 |
|
The number of entries the driver can buffer. Must be greater than zero. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
|
struct |
|
Meta data about a compressed video stream. Each element of the array corresponds to one picture, sorted in ascending order by their |
v4l2_enc_idx_entry
|
__u64 |
|
The offset in bytes from the beginning of the compressed video stream to the beginning of this picture, that is a PES packet header as defined in ISO 13818-1 or a picture header as defined in ISO 13818-2. When the encoder is stopped, the driver resets the offset to zero. |
|
__u64 |
|
The 33 bit Presentation Time Stamp of this picture as defined in ISO 13818-1. |
|
__u32 |
|
The length of this picture in bytes. |
|
__u32 |
|
Flags containing the coding type of this picture, see enc-idx-flags. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
|
|
0x00 |
This is an Intra-coded picture. |
|
|
0x01 |
This is a Predictive-coded picture. |
|
|
0x02 |
This is a Bidirectionally predictive-coded picture. |
|
|
0x0F |
AND the flags field with this mask to obtain the picture coding type. |
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.
ioctl VIDIOC_G_EXT_CTRLS, VIDIOC_S_EXT_CTRLS, VIDIOC_TRY_EXT_CTRLS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_EXT_CTRLS - VIDIOC_S_EXT_CTRLS - VIDIOC_TRY_EXT_CTRLS - Get or set the value of several controls, try control values
Synopsis #
int ioctl(int fd, VIDIOC_G_EXT_CTRLS, struct v4l2_ext_controls *argp)
int ioctl(int fd, VIDIOC_S_EXT_CTRLS, struct v4l2_ext_controls *argp)
int ioctl(int fd, VIDIOC_TRY_EXT_CTRLS, struct v4l2_ext_controls *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_ext_controls.
Description #
These ioctls allow the caller to get or set multiple controls atomically. Control IDs are grouped into control classes (see ctrl-class) and all controls in the control array must belong to the same control class.
Applications must always fill in the count, which, controls and reserved fields of struct v4l2_ext_controls, and initialize the struct v4l2_ext_control array pointed to by the controls fields.
To get the current value of a set of controls applications initialize the id, size and reserved2 fields of each struct v4l2_ext_control and call the VIDIOC_G_EXT_CTRLS ioctl. String controls must also set the string field. Controls of compound types (V4L2_CTRL_FLAG_HAS_PAYLOAD is set) must set the ptr field.
If the size is too small to receive the control result (only relevant for pointer-type controls like strings), then the driver will set size to a valid value and return an ENOSPC error code. You should re-allocate the memory to this new size and try again. For the string type it is possible that the same issue occurs again if the string has grown in the meantime. It is recommended to call ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU first and use maximum+1 as the new size value. It is guaranteed that that is sufficient memory.
N-dimensional arrays are set and retrieved row-by-row. You cannot set a partial array, all elements have to be set or retrieved. The total size is calculated as elems * elem_size. These values can be obtained by calling VIDIOC_QUERY_EXT_CTRL.
To change the value of a set of controls applications initialize the id, size, reserved2 and value/value64/string/ptr fields of each struct v4l2_ext_control and call the VIDIOC_S_EXT_CTRLS ioctl. The controls will only be set if all control values are valid.
To check if a set of controls have correct values applications initialize the id, size, reserved2 and value/value64/string/ptr fields of each struct v4l2_ext_control and call the VIDIOC_TRY_EXT_CTRLS ioctl. It is up to the driver whether wrong values are automatically adjusted to a valid value or if an error is returned.
When the id or which is invalid drivers return an EINVAL error code. When the value is out of bounds drivers can choose to take the closest valid value or return an ERANGE error code, whatever seems more appropriate. In the first case the new value is set in struct v4l2_ext_control. If the new control value is inappropriate (e.g. the given menu index is not supported by the menu control), then this will also result in an EINVAL error code error.
If request_fd is set to a not-yet-queued request file descriptor and which is set to V4L2_CTRL_WHICH_REQUEST_VAL, then the controls are not applied immediately when calling VIDIOC_S_EXT_CTRLS, but instead are applied by the driver for the buffer associated with the same request. If the device does not support requests, then EACCES will be returned. If requests are supported but an invalid request file descriptor is given, then EINVAL will be returned.
An attempt to call VIDIOC_S_EXT_CTRLS for a request that has already been queued will result in an EBUSY error.
If request_fd is specified and which is set to V4L2_CTRL_WHICH_REQUEST_VAL during a call to VIDIOC_G_EXT_CTRLS, then it will return the values of the controls at the time of request completion. If the request is not yet completed, then this will result in an EACCES error.
The driver will only set/get these controls if all control values are correct. This prevents the situation where only some of the controls were set/get. Only low-level errors (e. g. a failed i2c command) can still cause this situation.
v4l2_ext_control
|
__u32 |
|
Identifies the control, set by the application. |
|
__u32 |
|
The total size in bytes of the payload of this control. |
|
The |
||
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
union { |
(anonymous) |
|
|
__s32 |
|
New value or current value. Valid if this control is not of type |
|
__s64 |
|
New value or current value. Valid if this control is of type |
|
char * |
|
A pointer to a string. Valid if this control is of type |
|
__u8 * |
|
A pointer to a matrix control of unsigned 8-bit values. Valid if this control is of type |
|
__u16 * |
|
A pointer to a matrix control of unsigned 16-bit values. Valid if this control is of type |
|
__u32 * |
|
A pointer to a matrix control of unsigned 32-bit values. Valid if this control is of type |
|
__s32 * |
|
A pointer to a matrix control of signed 32-bit values. Valid if this control is of type |
|
__s64 * |
|
A pointer to a matrix control of signed 64-bit values. Valid if this control is of type |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
struct |
|
A pointer to a struct |
|
void * |
|
A pointer to a compound type which can be an N-dimensional array and/or a compound type (the control's type is >= |
|
} |
||
v4l2_ext_controls
|
union { |
(anonymous) |
|
|
__u32 |
|
Which value of the control to get/set/try. |
|
When using Whether a control supports querying the minimum and maximum values using For backwards compatibility you can also use a control class here (see ctrl-class). In that case all controls have to belong to that control class. This usage is deprecated, instead just use |
||
|
__u32 |
|
Deprecated name kept for backwards compatibility. Use |
|
} |
||
|
__u32 |
|
The number of controls in the controls array. May also be zero. |
|
__u32 |
|
Index of the failing control. Set by the driver in case of an error. |
|
If the error is associated with a particular control, then Before controls are read from/written to hardware a validation step takes place: this checks if all controls in the list are valid controls, if no attempt is made to write to a read-only control or read from a write-only control, and any other up-front checks that can be done without accessing the hardware. The exact validations done during this step are driver dependent since some checks might require hardware access for some devices, thus making it impossible to do those checks up-front. However, drivers should make a best-effort to do as many up-front checks as possible. This check is done to avoid leaving the hardware in an inconsistent state due to easy-to-avoid problems. But it leads to another problem: the application needs to know whether an error came from the validation step (meaning that the hardware was not touched) or from an error during the actual reading from/writing to hardware. The, in hindsight quite poor, solution for that is to set Since VIDIOC_TRY_EXT_CTRLS does not access hardware there is also no need to handle the validation step in this special way, so |
||
|
__s32 |
|
File descriptor of the request to be used by this operation. Only valid if |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
struct |
|
Pointer to an array of Ignored if |
|
|
0x980000 |
The class containing user controls. These controls are described in control. All controls that can be set using the VIDIOC_S_CTRL and VIDIOC_G_CTRL ioctl belong to this class. |
|
|
0x990000 |
The class containing stateful codec controls. These controls are described in Codec Control Reference. |
|
|
0x9a0000 |
The class containing camera controls. These controls are described in Camera Control Reference. |
|
|
0x9b0000 |
The class containing FM Transmitter (FM TX) controls. These controls are described in fm-tx-controls. |
|
|
0x9c0000 |
The class containing flash device controls. These controls are described in flash-controls. |
|
|
0x9d0000 |
The class containing JPEG compression controls. These controls are described in jpeg-controls. |
|
|
0x9e0000 |
The class containing image source controls. These controls are described in image-source-controls. |
|
|
0x9f0000 |
The class containing image processing controls. These controls are described in image-process-controls. |
|
|
0xa10000 |
The class containing FM Receiver (FM RX) controls. These controls are described in fm-rx-controls. |
|
|
0xa20000 |
The class containing RF tuner controls. These controls are described in rf-tuner-controls. |
|
|
0xa30000 |
The class containing motion or object detection controls. These controls are described in detect-controls. |
|
|
0xa40000 |
The class containing stateless codec controls. These controls are described in Stateless Codec Control Reference. |
|
|
0xa50000 |
The class containing colorimetry controls. These controls are described in colorimetry-controls. |
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.
-
EINVAL
The struct
v4l2_ext_controlidis invalid, or the structv4l2_ext_controlswhichis invalid, or the structv4l2_ext_controlvaluewas inappropriate (e.g. the given menu index is not supported by the driver), or thewhichfield was set toV4L2_CTRL_WHICH_REQUEST_VALbut the givenrequest_fdwas invalid orV4L2_CTRL_WHICH_REQUEST_VALis not supported by the kernel. This error code is also returned by the VIDIOC_S_EXT_CTRLS and VIDIOC_TRY_EXT_CTRLS ioctls if two or more control values are in conflict. -
ERANGE
The struct
v4l2_ext_controlvalueis out of bounds. -
EBUSY
The control is temporarily not changeable, possibly because another applications took over control of the device function this control belongs to, or (if the
whichfield was set toV4L2_CTRL_WHICH_REQUEST_VAL) the request was queued but not yet completed. -
ENOSPC
The space reserved for the control's payload is insufficient. The field
sizeis set to a value that is enough to store the payload and this error code is returned. -
EACCES
Attempt to try or set a read-only control, or to get a write-only control, or to get a control from a request that has not yet been completed.
Or the
whichfield was set toV4L2_CTRL_WHICH_REQUEST_VALbut the device does not support requests.Or if there is an attempt to set an inactive control and the driver is not capable of caching the new value until the control is active again.
ioctl VIDIOC_G_FBUF, VIDIOC_S_FBUF
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_FBUF - VIDIOC_S_FBUF - Get or set frame buffer overlay parameters
Synopsis #
int ioctl(int fd, VIDIOC_G_FBUF, struct v4l2_framebuffer *argp)
int ioctl(int fd, VIDIOC_S_FBUF, const struct v4l2_framebuffer *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_framebuffer.
Description #
Applications can use the VIDIOC_G_FBUF and VIDIOC_S_FBUF ioctl to get and set the framebuffer parameters for a Video Overlay or Video Output Overlay (OSD). The type of overlay is implied by the device type (capture or output device) and can be determined with the vidioc_querycap ioctl. One /dev/videoN device must not support both kinds of overlay.
The V4L2 API distinguishes destructive and non-destructive overlays. A destructive overlay copies captured video images into the video memory of a graphics card. A non-destructive overlay blends video images into a VGA signal or graphics into a video signal. Video Output Overlays are always non-destructive.
Destructive overlay support has been removed: with modern GPUs and CPUs this is no longer needed, and it was always a very dangerous feature.
To get the current parameters applications call the VIDIOC_G_FBUF ioctl with a pointer to a struct v4l2_framebuffer structure. The driver fills all fields of the structure or returns an EINVAL error code when overlays are not supported.
To set the parameters for a Video Output Overlay, applications must initialize the flags field of a struct v4l2_framebuffer. Since the framebuffer is implemented on the TV card all other parameters are determined by the driver. When an application calls VIDIOC_S_FBUF with a pointer to this structure, the driver prepares for the overlay and returns the framebuffer parameters as VIDIOC_G_FBUF does, or it returns an error code.
To set the parameters for a Video Capture Overlay applications must initialize the flags field, the fmt substructure, and call VIDIOC_S_FBUF. Again the driver prepares for the overlay and returns the framebuffer parameters as VIDIOC_G_FBUF does, or it returns an error code.
v4l2_framebuffer
|
__u32 |
|
Overlay capability flags set by the driver, see framebuffer-cap. |
|
|
__u32 |
|
Overlay control flags set by application and driver, see framebuffer-flags |
|
|
void * |
|
Physical base address of the framebuffer, that is the address of the pixel in the top left corner of the framebuffer. For VIDIOC_S_FBUF this field is no longer supported and the kernel will always set this to NULL. For Video Output Overlays the driver will return a valid base address, so applications can find the corresponding Linux framebuffer device (see osd). For Video Capture Overlays this field will always be NULL. |
|
|
struct |
|
Layout of the frame buffer. |
|
|
__u32 |
|
Width of the frame buffer in pixels. |
|
|
__u32 |
|
Height of the frame buffer in pixels. |
|
|
__u32 |
|
The pixel format of the framebuffer. |
|
|
For non-destructive Video Overlays this field only defines a format for the struct |
|||
|
For Video Output Overlays the driver must return a valid format. |
|||
|
Usually this is an RGB format (for example V4L2_PIX_FMT_RGB565) but YUV formats (only packed YUV formats when chroma keying is used, not including |
|||
|
enum |
|
Drivers and applications shall ignore this field. If applicable, the field order is selected with the VIDIOC_S_FMT ioctl, using the |
|
|
__u32 |
|
Distance in bytes between the leftmost pixels in two adjacent lines. |
|
|
This field is irrelevant to non-destructive Video Overlays. For Video Output Overlays the driver must return a valid value. Video hardware may access padding bytes, therefore they must reside in accessible memory. Consider for example the case where padding bytes after the last line of an image cross a system page boundary. Capture devices may write padding bytes, the value is undefined. Output devices ignore the contents of padding bytes. When the image format is planar the |
|||
|
__u32 |
|
This field is irrelevant to non-destructive Video Overlays. For Video Output Overlays the driver must return a valid format. Together with |
|
|
enum |
|
This information supplements the |
|
|
__u32 |
|
Reserved. Drivers and applications must set this field to zero. |
|
|
|
0x0001 |
The device is capable of non-destructive overlays. When the driver clears this flag, only destructive overlays are supported. There are no drivers yet which support both destructive and non-destructive overlays. Video Output Overlays are in practice always non-destructive. |
|
|
0x0002 |
The device supports clipping by chroma-keying the images. That is, image pixels replace pixels in the VGA or video signal only where the latter assume a certain color. Chroma-keying makes no sense for destructive overlays. |
|
|
0x0004 |
The device supports clipping using a list of clip rectangles. Note that this is no longer supported. |
|
|
0x0008 |
The device supports clipping using a bit mask. Note that this is no longer supported. |
|
|
0x0010 |
The device supports clipping/blending using the alpha channel of the framebuffer or VGA signal. Alpha blending makes no sense for destructive overlays. |
|
|
0x0020 |
The device supports alpha blending using a global alpha value. Alpha blending makes no sense for destructive overlays. |
|
|
0x0040 |
The device supports clipping/blending using the inverted alpha channel of the framebuffer or VGA signal. Alpha blending makes no sense for destructive overlays. |
|
|
0x0080 |
The device supports Source Chroma-keying. Video pixels with the chroma-key colors are replaced by framebuffer pixels, which is exactly opposite of |
|
|
0x0001 |
The framebuffer is the primary graphics surface. In other words, the overlay is destructive. This flag is typically set by any driver that doesn't have the |
|
|
0x0002 |
If this flag is set for a video capture device, then the driver will set the initial overlay size to cover the full framebuffer size, otherwise the existing overlay size (as set by VIDIOC_S_FMT) will be used. Only one video capture driver (bttv) supports this flag. The use of this flag for capture devices is deprecated. There is no way to detect which drivers support this flag, so the only reliable method of setting the overlay size is through VIDIOC_S_FMT. If this flag is set for a video output device, then the video output overlay window is relative to the top-left corner of the framebuffer and restricted to the size of the framebuffer. If it is cleared, then the video output overlay window is relative to the video output display. |
|
|
0x0004 |
Use chroma-keying. The chroma-key color is determined by the |
|
There are no flags to enable clipping using a list of clip rectangles or a bitmap. These methods are negotiated with the VIDIOC_S_FMT ioctl, see Video Overlay Interface and osd. |
||
|
|
0x0008 |
Use the alpha channel of the framebuffer to clip or blend framebuffer pixels with video images. The blend function is: output = framebuffer pixel * alpha + video pixel * (1 - alpha). The actual alpha depth depends on the framebuffer pixel format. |
|
|
0x0010 |
Use a global alpha value to blend the framebuffer with video images. The blend function is: output = (framebuffer pixel * alpha + video pixel * (255 - alpha)) / 255. The alpha value is determined by the |
|
|
0x0020 |
Like |
|
|
0x0040 |
Use source chroma-keying. The source chroma-key color is determined by the |
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.
-
EPERM
VIDIOC_S_FBUF can only be called by a privileged user to negotiate the parameters for a destructive overlay.
-
EINVAL
The VIDIOC_S_FBUF parameters are unsuitable.
ioctl VIDIOC_G_FMT, VIDIOC_S_FMT, VIDIOC_TRY_FMT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_FMT - VIDIOC_S_FMT - VIDIOC_TRY_FMT - Get or set the data format, try a format
Synopsis #
int ioctl(int fd, VIDIOC_G_FMT, struct v4l2_format *argp)
int ioctl(int fd, VIDIOC_S_FMT, struct v4l2_format *argp)
int ioctl(int fd, VIDIOC_TRY_FMT, struct v4l2_format *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_format.
Description #
These ioctls are used to negotiate the format of data (typically image format) exchanged between driver and application.
To query the current parameters applications set the type field of a struct v4l2_format to the respective buffer (stream) type. For example video capture devices use V4L2_BUF_TYPE_VIDEO_CAPTURE or V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE. When the application calls the VIDIOC_G_FMT ioctl with a pointer to this structure the driver fills the respective member of the fmt union. In case of video capture devices that is either the struct v4l2_pix_format pix or the struct v4l2_pix_format_mplane pix_mp member. When the requested buffer type is not supported drivers return an EINVAL error code.
To change the current format parameters applications initialize the type field and all fields of the respective fmt union member. For details see the documentation of the various devices types in Interfaces. Good practice is to query the current parameters first, and to modify only those parameters not suitable for the application. When the application calls the VIDIOC_S_FMT ioctl with a pointer to a struct v4l2_format structure the driver checks and adjusts the parameters against hardware abilities. Drivers should not return an error code unless the type field is invalid, this is a mechanism to fathom device capabilities and to approach parameters acceptable for both the application and driver. On success the driver may program the hardware, allocate resources and generally prepare for data exchange. Finally the VIDIOC_S_FMT ioctl returns the current format parameters as VIDIOC_G_FMT does. Very simple, inflexible devices may even ignore all input and always return the default parameters. However all V4L2 devices exchanging data with the application must implement the VIDIOC_G_FMT and VIDIOC_S_FMT ioctl. When the requested buffer type is not supported drivers return an EINVAL error code on a VIDIOC_S_FMT attempt. When I/O is already in progress or the resource is not available for other reasons drivers return the EBUSY error code.
The VIDIOC_TRY_FMT ioctl is equivalent to VIDIOC_S_FMT with one exception: it does not change driver state. It can also be called at any time, never returning EBUSY. This function is provided to negotiate parameters, to learn about hardware limitations, without disabling I/O or possibly time consuming hardware preparations. Although strongly recommended drivers are not required to implement this ioctl.
The format as returned by VIDIOC_TRY_FMT must be identical to what VIDIOC_S_FMT returns for the same input or output.
v4l2_format
|
__u32 |
|
Type of the data stream, see |
|
union { |
|
|
|
struct |
|
Definition of an image format, see Image Formats, used by video capture and output devices. |
|
struct |
|
Definition of an image format, see Image Formats, used by video capture and output devices that support the multi-planar version of the API. |
|
struct |
|
Definition of an overlaid image, see Video Overlay Interface, used by video overlay devices. |
|
struct |
|
Raw VBI capture or output parameters. This is discussed in more detail in Raw VBI Data Interface. Used by raw VBI capture and output devices. |
|
struct |
|
Sliced VBI capture or output parameters. See sliced for details. Used by sliced VBI capture and output devices. |
|
struct |
|
Definition of a data format, see Image Formats, used by SDR capture and output devices. |
|
struct |
|
Definition of a metadata format, see Metadata Formats, used by metadata capture devices. |
|
__u8 |
|
Place holder for future extensions. |
|
} |
||
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.
-
EINVAL
The struct
v4l2_formattypefield is invalid or the requested buffer type not supported. -
EBUSY
The device is busy and cannot change the format. This could be because or the device is streaming or buffers are allocated or queued to the driver. Relevant for VIDIOC_S_FMT only.
ioctl VIDIOC_G_FREQUENCY, VIDIOC_S_FREQUENCY
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_FREQUENCY - VIDIOC_S_FREQUENCY - Get or set tuner or modulator radio frequency
Synopsis #
int ioctl(int fd, VIDIOC_G_FREQUENCY, struct v4l2_frequency *argp)
int ioctl(int fd, VIDIOC_S_FREQUENCY, const struct v4l2_frequency *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_frequency.
Description #
To get the current tuner or modulator radio frequency applications set the tuner field of a struct v4l2_frequency to the respective tuner or modulator number (only input devices have tuners, only output devices have modulators), zero out the reserved array and call the VIDIOC_G_FREQUENCY ioctl with a pointer to this structure. The driver stores the current frequency in the frequency field.
To change the current tuner or modulator radio frequency applications initialize the tuner, type and frequency fields, and the reserved array of a struct v4l2_frequency and call the VIDIOC_S_FREQUENCY ioctl with a pointer to this structure. When the requested frequency is not possible the driver assumes the closest possible value. However VIDIOC_S_FREQUENCY is a write-only ioctl, it does not return the actual new frequency.
v4l2_frequency
|
__u32 |
|
The tuner or modulator index number. This is the same value as in the struct |
|
__u32 |
|
The tuner type. This is the same value as in the struct |
|
__u32 |
|
Tuning frequency in units of 62.5 kHz, or if the struct |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
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.
-
EINVAL
The
tunerindex is out of bounds or the value in thetypefield is wrong. -
EBUSY
A hardware seek is in progress.
ioctl VIDIOC_G_INPUT, VIDIOC_S_INPUT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_INPUT - VIDIOC_S_INPUT - Query or select the current video input
Synopsis #
int ioctl(int fd, VIDIOC_G_INPUT, int *argp)
int ioctl(int fd, VIDIOC_S_INPUT, int *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer an integer with input index.
Description #
To query the current video input applications call the VIDIOC_G_INPUT ioctl with a pointer to an integer where the driver stores the number of the input, as in the struct v4l2_input index field. This ioctl will fail only when there are no video inputs, returning EINVAL.
To select a video input applications store the number of the desired input in an integer and call the VIDIOC_S_INPUT ioctl with a pointer to this integer. Side effects are possible. For example inputs may support different video standards, so the driver may implicitly switch the current standard. Because of these possible side effects applications must select an input before querying or negotiating any other parameters.
Information about video inputs is available using the ioctl VIDIOC_ENUMINPUT ioctl.
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.
-
EINVAL
The number of the video input is out of bounds.
ioctl VIDIOC_G_JPEGCOMP, VIDIOC_S_JPEGCOMP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_JPEGCOMP - VIDIOC_S_JPEGCOMP
Synopsis #
int ioctl(int fd, VIDIOC_G_JPEGCOMP, v4l2_jpegcompression *argp)
int ioctl(int fd, VIDIOC_S_JPEGCOMP, const v4l2_jpegcompression *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_jpegcompression.
Description #
These ioctls are deprecated. New drivers and applications should use JPEG class controls for image quality and JPEG markers control.
[to do]
Ronald Bultje elaborates:
APP is some application-specific information. The application can set it itself, and it'll be stored in the JPEG-encoded fields (eg; interlacing information for in an AVI or so). COM is the same, but it's comments, like 'encoded by me' or so.
jpeg_markers describes whether the huffman tables, quantization tables and the restart interval information (all JPEG-specific stuff) should be stored in the JPEG-encoded fields. These define how the JPEG field is encoded. If you omit them, applications assume you've used standard encoding. You usually do want to add them.
v4l2_jpegcompression
|
int |
|
Deprecated. If V4L2_CID_JPEG_COMPRESSION_QUALITY control is exposed by a driver applications should use it instead and ignore this field. |
|
int |
|
|
|
int |
|
|
|
char |
|
|
|
int |
|
|
|
char |
|
|
|
__u32 |
|
See jpeg-markers. Deprecated. If V4L2_CID_JPEG_ACTIVE_MARKER control is exposed by a driver applications should use it instead and ignore this field. |
|
|
(1<<3) |
Define Huffman Tables |
|
|
(1<<4) |
Define Quantization Tables |
|
|
(1<<5) |
Define Restart Interval |
|
|
(1<<6) |
Comment segment |
|
|
(1<<7) |
App segment, driver will always use APP0 |
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.
ioctl VIDIOC_G_MODULATOR, VIDIOC_S_MODULATOR
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_MODULATOR - VIDIOC_S_MODULATOR - Get or set modulator attributes
Synopsis #
int ioctl(int fd, VIDIOC_G_MODULATOR, struct v4l2_modulator *argp)
int ioctl(int fd, VIDIOC_S_MODULATOR, const struct v4l2_modulator *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_modulator.
Description #
To query the attributes of a modulator applications initialize the index field and zero out the reserved array of a struct v4l2_modulator and call the VIDIOC_G_MODULATOR ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all modulators applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
Modulators have two writable properties, an audio modulation set and the radio frequency. To change the modulated audio subprograms, applications initialize the index and txsubchans fields and the reserved array and call the VIDIOC_S_MODULATOR ioctl. Drivers may choose a different audio modulation if the request cannot be satisfied. However this is a write-only ioctl, it does not return the actual audio modulation selected.
SDR specific modulator types are V4L2_TUNER_SDR and V4L2_TUNER_RF. For SDR devices txsubchans field must be initialized to zero. The term 'modulator' means SDR transmitter in this context.
To change the radio frequency the VIDIOC_S_FREQUENCY ioctl is available.
v4l2_modulator
|
__u32 |
|
Identifies the modulator, set by the application. |
||
|
__u8 |
|
Name of the modulator, a NUL-terminated ASCII string. This information is intended for the user. |
||
|
__u32 |
|
Modulator capability flags. No flags are defined for this field, the tuner flags in struct |
||
|
__u32 |
|
The lowest tunable frequency in units of 62.5 KHz, or if the |
||
|
__u32 |
|
The highest tunable frequency in units of 62.5 KHz, or if the |
||
|
__u32 |
|
With this field applications can determine how audio sub-carriers shall be modulated. It contains a set of flags as defined in modulator-txsubchans. |
||
|
__u32 |
|
Type of the modulator, see |
||
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
||
|
|
0x0001 |
Modulate channel 1 as mono audio, when the input has more channels, a down-mix of channel 1 and 2. This flag does not combine with |
|
|
0x0002 |
Modulate channel 1 and 2 as left and right channel of a stereo audio signal. When the input has only one channel or two channels and |
|
|
0x0008 |
Modulate channel 1 and 2 as primary and secondary language of a bilingual audio signal. When the input has only one channel it is used for both languages. It is not possible to encode the primary or secondary language only. This flag does not combine with |
|
|
0x0004 |
Same effect as |
|
|
0x0004 |
When combined with |
|
|
0x0010 |
Enable the RDS encoder for a radio FM transmitter. |
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.
-
EINVAL
The struct
v4l2_modulatorindexis out of bounds.
ioctl VIDIOC_G_OUTPUT, VIDIOC_S_OUTPUT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_OUTPUT - VIDIOC_S_OUTPUT - Query or select the current video output
Synopsis #
int ioctl(int fd, VIDIOC_G_OUTPUT, int *argp)
int ioctl(int fd, VIDIOC_S_OUTPUT, int *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to an integer with output index.
Description #
To query the current video output applications call the VIDIOC_G_OUTPUT ioctl with a pointer to an integer where the driver stores the number of the output, as in the struct v4l2_output index field. This ioctl will fail only when there are no video outputs, returning the EINVAL error code.
To select a video output applications store the number of the desired output in an integer and call the VIDIOC_S_OUTPUT ioctl with a pointer to this integer. Side effects are possible. For example outputs may support different video standards, so the driver may implicitly switch the current standard. Because of these possible side effects applications must select an output before querying or negotiating any other parameters.
Information about video outputs is available using the ioctl VIDIOC_ENUMOUTPUT ioctl.
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.
-
EINVAL
The number of the video output is out of bounds, or there are no video outputs at all.
ioctl VIDIOC_G_PARM, VIDIOC_S_PARM
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_PARM - VIDIOC_S_PARM - Get or set streaming parameters
Synopsis #
int ioctl(int fd, VIDIOC_G_PARM, v4l2_streamparm *argp)
int ioctl(int fd, VIDIOC_S_PARM, v4l2_streamparm *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_streamparm.
Description #
Applications can request a different frame interval. The capture or output device will be reconfigured to support the requested frame interval if possible. Optionally drivers may choose to skip or repeat frames to achieve the requested frame interval.
For stateful encoders (see Memory-to-Memory Stateful Video Encoder Interface) this represents the frame interval that is typically embedded in the encoded video stream.
Changing the frame interval shall never change the format. Changing the format, on the other hand, may change the frame interval.
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.
v4l2_streamparm
|
__u32 |
|
The buffer (stream) type, same as struct |
|
union { |
|
|
|
struct |
|
Parameters for capture devices, used when |
|
struct |
|
Parameters for output devices, used when |
|
__u8 |
|
A place holder for future extensions. |
|
} |
||
v4l2_captureparm
|
__u32 |
|
See parm-caps. |
|
__u32 |
|
Set by drivers and applications, see parm-flags. |
|
struct |
|
This is the desired period between successive frames captured by the driver, in seconds. |
|
This will configure the speed at which the video source (e.g. a sensor) generates video frames. If the speed is fixed, then the driver may choose to skip or repeat frames in order to achieve the requested frame rate. For stateful encoders (see Memory-to-Memory Stateful Video Encoder Interface) this represents the frame interval that is typically embedded in the encoded video stream. Applications store here the desired frame period, drivers return the actual frame period. 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 |
||
|
__u32 |
|
Custom (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 Querying Capabilities. |
|
__u32 |
|
Applications set this field to the desired number of buffers used internally by the driver in |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
v4l2_outputparm
|
__u32 |
|
See parm-caps. |
|
__u32 |
|
Set by drivers and applications, see parm-flags. |
|
struct |
|
This 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 For stateful encoders (see Memory-to-Memory Stateful Video Encoder Interface) this represents the frame interval that is typically embedded in the encoded video stream and it provides a hint to the encoder of the speed at which raw frames are queued up to the encoder. Applications store here the desired frame period, drivers return the actual frame period. 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 |
||
|
__u32 |
|
Custom (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 Querying Capabilities. |
|
__u32 |
|
Applications set this field to the desired number of buffers used internally by the driver in |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
|
0x1000 |
The frame period can be modified by setting the |
|
|
0x0001 |
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 regular motion video capture modes. In high quality mode:
|
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.
ioctl VIDIOC_G_PRIORITY, VIDIOC_S_PRIORITY
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_PRIORITY - VIDIOC_S_PRIORITY - Query or request the access priority associated with a file descriptor
Synopsis #
int ioctl(int fd, VIDIOC_G_PRIORITY, enum v4l2_priority *argp)
int ioctl(int fd, VIDIOC_S_PRIORITY, const enum v4l2_priority *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to an enum
v4l2_prioritytype.
Description #
To query the current access priority applications call the VIDIOC_G_PRIORITY ioctl with a pointer to an enum v4l2_priority variable where the driver stores the current priority.
To request an access priority applications store the desired priority in an enum v4l2_priority variable and call VIDIOC_S_PRIORITY ioctl with a pointer to this variable.
v4l2_priority
|
|
0 |
|
|
|
1 |
Lowest priority, usually applications running in background, for example monitoring VBI transmissions. A proxy application running in user space will be necessary if multiple applications want to read from a device at this priority. |
|
|
2 |
|
|
|
2 |
Medium priority, usually applications started and interactively controlled by the user. For example TV viewers, Teletext browsers, or just "panel" applications to change the channel or video controls. This is the default priority unless an application requests another. |
|
|
3 |
Highest priority. Only one file descriptor can have this priority, it blocks any other fd from changing device properties. Usually applications which must not be interrupted, like video recording. |
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.
-
EINVAL
The requested priority value is invalid.
-
EBUSY
Another application already requested higher priority.
ioctl VIDIOC_G_SELECTION, VIDIOC_S_SELECTION
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_SELECTION - VIDIOC_S_SELECTION - Get or set one of the selection rectangles
Synopsis #
int ioctl(int fd, VIDIOC_G_SELECTION, struct v4l2_selection *argp)
int ioctl(int fd, VIDIOC_S_SELECTION, struct v4l2_selection *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_selection.
Description #
The ioctls are used to query and configure selection rectangles.
To query the cropping (composing) rectangle set struct v4l2_selection type field to the respective buffer type. The next step is setting the value of struct v4l2_selection target field to V4L2_SEL_TGT_CROP (V4L2_SEL_TGT_COMPOSE). Please refer to table Common selection definitions or Cropping, composing and scaling -- the SELECTION API for additional targets. The flags and reserved fields of struct v4l2_selection are ignored and they must be filled with zeros. The driver fills the rest of the structure or returns EINVAL error code if incorrect buffer type or target was used. If cropping (composing) is not supported then the active rectangle is not mutable and it is always equal to the bounds rectangle. Finally, the struct v4l2_rect r rectangle is filled with the current cropping (composing) coordinates. The coordinates are expressed in driver-dependent units. The only exception are rectangles for images in raw formats, whose coordinates are always expressed in pixels.
To change the cropping (composing) rectangle set the struct v4l2_selection type field to the respective buffer type. The next step is setting the value of struct v4l2_selection target to V4L2_SEL_TGT_CROP (V4L2_SEL_TGT_COMPOSE). Please refer to table Common selection definitions or Cropping, composing and scaling -- the SELECTION API for additional targets. The struct v4l2_rect r rectangle need to be set to the desired active area. Field struct v4l2_selection reserved is ignored and must be filled with zeros. The driver may adjust coordinates of the requested rectangle. An application may introduce constraints to control rounding behaviour. The struct v4l2_selection flags field must be set to one of the following:
-
0- The driver can adjust the rectangle size freely and shall choose a crop/compose rectangle as close as possible to the requested one. -
V4L2_SEL_FLAG_GE- The driver is not allowed to shrink the rectangle. The original rectangle must lay inside the adjusted one. -
V4L2_SEL_FLAG_LE- The driver is not allowed to enlarge the rectangle. The adjusted rectangle must lay inside the original one. -
V4L2_SEL_FLAG_GE | V4L2_SEL_FLAG_LE- The driver must choose the size exactly the same as in the requested rectangle.
Please refer to sel-const-adjust.
The driver may have to adjusts the requested dimensions against hardware limits and other parts as the pipeline, i.e. the bounds given by the capture/output window or TV display. The closest possible values of horizontal and vertical offset and sizes are chosen according to following priority:
-
Satisfy constraints from struct
v4l2_selectionflags. -
Adjust width, height, left, and top to hardware limits and alignments.
-
Keep center of adjusted rectangle as close as possible to the original one.
-
Keep width and height as close as possible to original ones.
-
Keep horizontal and vertical offset as close as possible to original ones.
On success the struct v4l2_rect r field contains the adjusted rectangle. When the parameters are unsuitable the application may modify the cropping (composing) or image parameters and repeat the cycle until satisfactory parameters have been negotiated. If constraints flags have to be violated at then ERANGE is returned. The error indicates that there exist no rectangle that satisfies the constraints.
Selection targets and flags are documented in Common selection definitions.
Size adjustments with constraint flags.
Behaviour of rectangle adjustment for different constraint flags.
v4l2_selection
|
__u32 |
|
Type of the buffer (from enum |
|
__u32 |
|
Used to select between cropping and composing rectangles. |
|
__u32 |
|
Flags controlling the selection rectangle adjustments, refer to selection flags. |
|
struct |
|
The selection rectangle. |
|
__u32 |
|
Reserved fields for future use. Drivers and applications must zero this array. |
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.
-
EINVAL
Given buffer type
typeor the selection targettargetis not supported, or theflagsargument is not valid. -
ERANGE
It is not possible to adjust struct
v4l2_rectrrectangle to satisfy all constraints given in theflagsargument. -
ENODATA
Selection is not supported for this input or output.
-
EBUSY
It is not possible to apply change of the selection rectangle at the moment. Usually because streaming is in progress.
ioctl VIDIOC_G_SLICED_VBI_CAP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_SLICED_VBI_CAP - Query sliced VBI capabilities
Synopsis #
int ioctl(int fd, VIDIOC_G_SLICED_VBI_CAP, struct v4l2_sliced_vbi_cap *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_sliced_vbi_cap.
Description #
To find out which data services are supported by a sliced VBI capture or output device, applications initialize the type field of a struct v4l2_sliced_vbi_cap, clear the reserved array and call the VIDIOC_G_SLICED_VBI_CAP ioctl. The driver fills in the remaining fields or returns an EINVAL error code if the sliced VBI API is unsupported or type is invalid.
v4l2_sliced_vbi_cap
|
__u16 |
|
A set of all data services supported by the driver. Equal to the union of all elements of the |
||
|
__u16 |
|
Each element of this array contains a set of data services the hardware can look for or insert into a particular scan line. Data services are defined in vbi-services. Array indices map to ITU-R line numbers1 as follows: |
||
|
Element |
525 line systems |
625 line systems |
||
|
|
1 |
1 |
||
|
|
23 |
23 |
||
|
|
264 |
314 |
||
|
|
286 |
336 |
||
|
The number of VBI lines the hardware can capture or output per frame, or the number of services it can identify on a given line may be limited. For example on PAL line 16 the hardware may be able to look for a VPS or Teletext signal, but not both at the same time. Applications can learn about these limits using the VIDIOC_S_FMT ioctl as described in Sliced VBI Data Interface. |
||||
|
Drivers must set |
||||
|
__u32 |
|
Type of the data stream, see |
||
|
__u32 |
|
This array is reserved for future extensions. Applications and drivers must set it to zero. |
||
[1] See also vbi-525 and vbi-625.
|
Symbol |
Value |
Reference |
Lines, usually |
Payload |
|---|---|---|---|---|
|
|
0x0001 |
PAL/SECAM line 7-22, 320-335 (second field 7-22) |
Last 42 of the 45 byte Teletext packet, that is without clock run-in and framing code, lsb first transmitted. |
|
|
|
0x0400 |
PAL line 16 |
Byte number 3 to 15 according to Figure 9 of ETS 300 231, lsb first transmitted. |
|
|
|
0x1000 |
NTSC line 21, 284 (second field 21) |
Two bytes in transmission order, including parity bit, lsb first transmitted. |
|
|
|
0x4000 |
PAL/SECAM line 23 |
See V4L2_SLICED_VBI_CAP WSS_625 payload below. |
|
|
|
0x1000 |
Set of services applicable to 525 line systems. |
||
|
|
0x4401 |
Set of services applicable to 625 line systems. |
||
V4L2_SLICED_VBI_CAP WSS_625 payload #
The payload for V4L2_SLICED_WSS_625 is:
Byte
0
1
Bit
msb
lsb
msb
lsb
7
6
5
4
3
2
1
0
x
x
13
12
11
10
9
8
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.
-
EINVAL
The value in the
typefield is wrong.
ioctl VIDIOC_G_STD, VIDIOC_S_STD, VIDIOC_SUBDEV_G_STD, VIDIOC_SUBDEV_S_STD
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_STD - VIDIOC_S_STD - VIDIOC_SUBDEV_G_STD - VIDIOC_SUBDEV_S_STD - Query or select the video standard of the current input
Synopsis #
int ioctl(int fd, VIDIOC_G_STD, v4l2_std_id *argp)
int ioctl(int fd, VIDIOC_S_STD, const v4l2_std_id *argp)
int ioctl(int fd, VIDIOC_SUBDEV_G_STD, v4l2_std_id *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_STD, const v4l2_std_id *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to
v4l2_std_id.
Description #
To query and select the current video standard applications use the VIDIOC_G_STD and VIDIOC_S_STD ioctls which take a pointer to a v4l2_std_id type as argument. VIDIOC_G_STD can return a single flag or a set of flags as in struct v4l2_standard field id. The flags must be unambiguous such that they appear in only one enumerated struct v4l2_standard structure.
VIDIOC_S_STD accepts one or more flags, being a write-only ioctl it does not return the actual new standard as VIDIOC_G_STD does. When no flags are given or the current input does not support the requested standard the driver returns an EINVAL error code. When the standard set is ambiguous drivers may return EINVAL or choose any of the requested standards. If the current input or output does not support standard video timings (e.g. if ioctl VIDIOC_ENUMINPUT does not set the V4L2_IN_CAP_STD flag), then ENODATA error code is returned.
Calling VIDIOC_SUBDEV_S_STD on a subdev device node that has been registered in read-only mode is not allowed. An error is returned and the errno variable is set to -EPERM.
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.
-
EINVAL
The VIDIOC_S_STD parameter was unsuitable.
-
ENODATA
Standard video timings are not supported for this input or output.
-
EPERM
VIDIOC_SUBDEV_S_STDhas been called on a read-only subdevice.
ioctl VIDIOC_G_TUNER, VIDIOC_S_TUNER
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_G_TUNER - VIDIOC_S_TUNER - Get or set tuner attributes
Synopsis #
int ioctl(int fd, VIDIOC_G_TUNER, struct v4l2_tuner *argp)
int ioctl(int fd, VIDIOC_S_TUNER, const struct v4l2_tuner *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_tuner.
Description #
To query the attributes of a tuner applications initialize the index field and zero out the reserved array of a struct v4l2_tuner and call the VIDIOC_G_TUNER ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code when the index is out of bounds. To enumerate all tuners applications shall begin at index zero, incrementing by one until the driver returns EINVAL.
Tuners have two writable properties, the audio mode and the radio frequency. To change the audio mode, applications initialize the index, audmode and reserved fields and call the VIDIOC_S_TUNER ioctl. This will not change the current tuner, which is determined by the current video input. Drivers may choose a different audio mode if the requested mode is invalid or unsupported. Since this is a write-only ioctl, it does not return the actually selected audio mode.
SDR specific tuner types are V4L2_TUNER_SDR and V4L2_TUNER_RF. For SDR devices audmode field must be initialized to zero. The term 'tuner' means SDR receiver in this context.
To change the radio frequency the VIDIOC_S_FREQUENCY ioctl is available.
v4l2_tuner
|
__u32 |
|
Identifies the tuner, set by the application. |
|
|
__u8 |
|
Name of the tuner, a NUL-terminated ASCII string. This information is intended for the user. |
|
|
__u32 |
|
Type of the tuner, see |
|
|
__u32 |
|
Tuner capability flags, see tuner-capability. Audio flags indicate the ability to decode audio subprograms. They will not change, for example with the current video standard. When the structure refers to a radio tuner the If multiple frequency bands are supported, then |
|
|
__u32 |
|
The lowest tunable frequency in units of 62.5 kHz, or if the |
|
|
__u32 |
|
The highest tunable frequency in units of 62.5 kHz, or if the |
|
|
__u32 |
|
Some tuners or audio decoders can determine the received audio subprograms by analyzing audio carriers, pilot tones or other indicators. To pass this information drivers set flags defined in tuner-rxsubchans in this field. For example: |
|
|
|
receiving mono audio |
||
|
|
receiving stereo audio and a secondary audio program |
||
|
|
receiving mono or stereo audio, the hardware cannot distinguish |
||
|
|
receiving bilingual audio |
||
|
|
receiving mono, stereo or bilingual audio |
||
|
When the This field is valid only if this is the tuner of the current video input, or when the structure refers to a radio tuner. |
|||
|
__u32 |
|
The selected audio mode, see tuner-audmode for valid values. The audio mode does not affect audio subprogram detection, and like a control it does not automatically change unless the requested mode is invalid or unsupported. See tuner-matrix for possible results when the selected and received audio programs do not match. Currently this is the only field of struct struct |
|
|
__u32 |
|
The signal strength if known. Ranging from 0 to 65535. Higher values indicate a better signal. |
|
|
__s32 |
|
Automatic frequency control. When the |
|
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
v4l2_tuner_type
|
|
1 |
Tuner supports radio |
|
|
2 |
Tuner supports analog TV |
|
|
4 |
Tuner controls the A/D and/or D/A block of a Software Digital Radio (SDR) |
|
|
5 |
Tuner controls the RF part of a Software Digital Radio (SDR) |
|
|
0x0001 |
When set, tuning frequencies are expressed in units of 62.5 Hz instead of 62.5 kHz. |
|
|
0x0002 |
This is a multi-standard tuner; the video standard can or must be switched. (B/G PAL tuners for example are typically not considered multi-standard because the video standard is automatically determined from the frequency band.) The set of supported video standards is available from the struct |
|
|
0x0004 |
If set, then this tuner supports the hardware seek functionality where the seek stops when it reaches the end of the frequency range. |
|
|
0x0008 |
If set, then this tuner supports the hardware seek functionality where the seek wraps around when it reaches the end of the frequency range. |
|
|
0x0010 |
Stereo audio reception is supported. |
|
|
0x0040 |
Reception of the primary language of a bilingual audio program is supported. Bilingual audio is a feature of two-channel systems, transmitting the primary language monaural on the main audio carrier and a secondary language monaural on a second carrier. Only |
|
|
0x0020 |
Reception of the secondary language of a bilingual audio program is supported. Only |
|
|
0x0020 |
Reception of a secondary audio program is supported. This is a feature of the BTSC system which accompanies the NTSC video standard. Two audio carriers are available for mono or stereo transmissions of a primary language, and an independent third carrier for a monaural secondary language. Only |
|
|
0x0080 |
RDS capture is supported. This capability is only valid for radio tuners. |
|
|
0x0100 |
The RDS data is passed as unparsed RDS blocks. |
|
|
0x0200 |
The RDS data is parsed by the hardware and set via controls. |
|
|
0x0400 |
The vidioc_enum_freq_bands ioctl can be used to enumerate the available frequency bands. |
|
|
0x0800 |
The range to search when using the hardware seek functionality is programmable, see vidioc_s_hw_freq_seek for details. |
|
|
0x1000 |
When set, tuning frequencies are expressed in units of 1 Hz instead of 62.5 kHz. |
|
|
0x0001 |
The tuner receives a mono audio signal. |
|
|
0x0002 |
The tuner receives a stereo audio signal. |
|
|
0x0008 |
The tuner receives the primary language of a bilingual audio signal. Drivers must clear this flag when the current video standard is |
|
|
0x0004 |
The tuner receives the secondary language of a bilingual audio signal (or a second audio program). |
|
|
0x0004 |
The tuner receives a Second Audio Program. |
|
|
0x0010 |
The tuner receives an RDS channel. |
|
|
0 |
Play mono audio. When the tuner receives a stereo signal this a down-mix of the left and right channel. When the tuner receives a bilingual or SAP signal this mode selects the primary language. |
|
|
1 |
Play stereo audio. When the tuner receives bilingual audio it may play different languages on the left and right channel or the primary language is played on both channels. Playing different languages in this mode is deprecated. New drivers should do this only in When the tuner receives no stereo signal or does not support stereo reception the driver shall fall back to |
|
|
3 |
Play the primary language, mono or stereo. Only |
|
|
2 |
Play the secondary language, mono. When the tuner receives no bilingual audio or SAP, or their reception is not supported the driver shall fall back to mono or stereo mode. Only |
|
|
2 |
Play the Second Audio Program. When the tuner receives no bilingual audio or SAP, or their reception is not supported the driver shall fall back to mono or stereo mode. Only |
|
|
4 |
Play the primary language on the left channel, the secondary language on the right channel. When the tuner receives no bilingual audio or SAP, it shall fall back to |
|
Selected |
|||||
|---|---|---|---|---|---|
|
Received |
|
|
|
|
|
|
|
Mono |
Mono/Mono |
Mono |
Mono |
Mono/Mono |
|
|
Mono |
Mono/Mono |
Mono |
SAP |
Mono/SAP (preferred) or Mono/Mono |
|
|
L+R |
L/R |
Stereo L/R (preferred) or Mono L+R |
Stereo L/R (preferred) or Mono L+R |
L/R (preferred) or L+R/L+R |
|
|
L+R |
L/R |
Stereo L/R (preferred) or Mono L+R |
SAP |
L+R/SAP (preferred) or L/R or L+R/L+R |
|
|
Language 1 |
Lang1/Lang2 (deprecated2) or Lang1/Lang1 |
Language 1 |
Language 2 |
Lang1/Lang2 (preferred) or Lang1/Lang1 |
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.
-
EINVAL
The struct
v4l2_tunerindexis out of bounds.
[1] This mode has been added in Linux 2.6.17 and may not be supported by older drivers.
[2] Playback of both languages in MODE_STEREO is deprecated. In the future drivers should produce only the primary language in this mode. Applications should request MODE_LANG1_LANG2 to record both languages or a stereo signal.
ioctl VIDIOC_LOG_STATUS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_LOG_STATUS - Log driver status information
Synopsis #
int ioctl(int fd, VIDIOC_LOG_STATUS)
Arguments #
-
fdFile descriptor returned by
open().
Description #
As the video/audio devices become more complicated it becomes harder to debug problems. When this ioctl is called the driver will output the current device status to the kernel log. This is particular useful when dealing with problems like no sound, no video and incorrectly tuned channels. Also many modern devices autodetect video and audio standards and this ioctl will report what the device thinks what the standard is. Mismatches may give an indication where the problem is.
This ioctl is optional and not all drivers support it. It was introduced in Linux 2.6.15.
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.
ioctl VIDIOC_OVERLAY
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_OVERLAY - Start or stop video overlay
Synopsis #
int ioctl(int fd, VIDIOC_OVERLAY, const int *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to an integer.
Description #
This ioctl is part of the video overlay I/O method. Applications call ioctl VIDIOC_OVERLAY to start or stop the overlay. It takes a pointer to an integer which must be set to zero by the application to stop overlay, to one to start.
Drivers do not support ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF or VIDIOC_STREAMOFF with V4L2_BUF_TYPE_VIDEO_OVERLAY.
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.
-
EINVAL
The overlay parameters have not been set up. See Video Overlay Interface for the necessary steps.
ioctl VIDIOC_PREPARE_BUF
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_PREPARE_BUF - Prepare a buffer for I/O
Synopsis #
int ioctl(int fd, VIDIOC_PREPARE_BUF, struct v4l2_buffer *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_buffer.
Description #
Applications can optionally call the ioctl VIDIOC_PREPARE_BUF ioctl to pass ownership of the buffer to the driver before actually enqueuing it, using the VIDIOC_QBUF ioctl, and to prepare it for future I/O. Such preparations may include cache invalidation or cleaning. Performing them in advance saves time during the actual I/O.
The struct v4l2_buffer structure is specified in buffer.
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.
-
EBUSY
File I/O is in progress.
-
EINVAL
The buffer
typeis not supported, or theindexis out of bounds, or no buffers have been allocated yet, or theuserptrorlengthare invalid.
ioctl VIDIOC_QBUF, VIDIOC_DQBUF
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_QBUF - VIDIOC_DQBUF - Exchange a buffer with the driver
Synopsis #
int ioctl(int fd, VIDIOC_QBUF, struct v4l2_buffer *argp)
int ioctl(int fd, VIDIOC_DQBUF, struct v4l2_buffer *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_buffer.
Description #
Applications call the VIDIOC_QBUF ioctl to enqueue an empty (capturing) or filled (output) buffer in the driver's incoming queue. The semantics depend on the selected I/O method.
To enqueue a buffer applications set the type field of a struct v4l2_buffer to the same buffer type as was previously used with struct v4l2_format type and struct v4l2_requestbuffers type. Applications must also set the index field. Valid index numbers range from zero to the number of buffers allocated with vidioc_reqbufs (struct v4l2_requestbuffers count) minus one. The contents of the struct v4l2_buffer returned by a ioctl VIDIOC_QUERYBUF ioctl will do as well. When the buffer is intended for output (type is V4L2_BUF_TYPE_VIDEO_OUTPUT, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, or V4L2_BUF_TYPE_VBI_OUTPUT) applications must also initialize the bytesused, field and timestamp fields, see buffer for details. Applications must also set flags to 0. The reserved2 and reserved fields must be set to 0. When using the multi-planar API, the m.planes field must contain a userspace pointer to a filled-in array of struct v4l2_plane and the length field must be set to the number of elements in that array.
To enqueue a memory mapped buffer applications set the memory field to V4L2_MEMORY_MMAP. When VIDIOC_QBUF is called with a pointer to this structure the driver sets the V4L2_BUF_FLAG_MAPPED and V4L2_BUF_FLAG_QUEUED flags and clears the V4L2_BUF_FLAG_DONE flag in the flags field, or it returns an EINVAL error code.
To enqueue a user pointer buffer applications set the memory field to V4L2_MEMORY_USERPTR, the m.userptr field to the address of the buffer and length to its size. When the multi-planar API is used, m.userptr and length members of the passed array of struct v4l2_plane have to be used instead. When VIDIOC_QBUF is called with a pointer to this structure the driver sets the V4L2_BUF_FLAG_QUEUED flag and clears the V4L2_BUF_FLAG_MAPPED and V4L2_BUF_FLAG_DONE flags in the flags field, or it returns an error code. This ioctl locks the memory pages of the buffer in physical memory, they cannot be swapped out to disk. Buffers remain locked until dequeued, until the VIDIOC_STREAMOFF or vidioc_reqbufs ioctl is called, or until the device is closed.
To enqueue a DMABUF buffer applications set the memory field to V4L2_MEMORY_DMABUF and the m.fd field to a file descriptor associated with a DMABUF buffer. When the multi-planar API is used the m.fd fields of the passed array of struct v4l2_plane have to be used instead. When VIDIOC_QBUF is called with a pointer to this structure the driver sets the V4L2_BUF_FLAG_QUEUED flag and clears the V4L2_BUF_FLAG_MAPPED and V4L2_BUF_FLAG_DONE flags in the flags field, or it returns an error code. This ioctl locks the buffer. Locking a buffer means passing it to a driver for a hardware access (usually DMA). If an application accesses (reads/writes) a locked buffer then the result is undefined. Buffers remain locked until dequeued, until the VIDIOC_STREAMOFF or vidioc_reqbufs ioctl is called, or until the device is closed.
The request_fd field can be used with the VIDIOC_QBUF ioctl to specify the file descriptor of a request, if requests are in use. Setting it means that the buffer will not be passed to the driver until the request itself is queued. Also, the driver will apply any settings associated with the request for this buffer. This field will be ignored unless the V4L2_BUF_FLAG_REQUEST_FD flag is set. If the device does not support requests, then EBADR will be returned. If requests are supported but an invalid request file descriptor is given, then EINVAL will be returned.
Applications call the VIDIOC_DQBUF ioctl to dequeue a filled (capturing) or displayed (output) buffer from the driver's outgoing queue. They just set the type, memory and reserved fields of a struct v4l2_buffer as above, when VIDIOC_DQBUF is called with a pointer to this structure the driver fills all remaining fields or returns an error code. The driver may also set V4L2_BUF_FLAG_ERROR in the flags field. It indicates a non-critical (recoverable) streaming error. In such case the application may continue as normal, but should be aware that data in the dequeued buffer might be corrupted. When using the multi-planar API, the planes array must be passed in as well.
If the application sets the memory field to V4L2_MEMORY_DMABUF to dequeue a DMABUF buffer, the driver fills the m.fd field with a file descriptor numerically the same as the one given to VIDIOC_QBUF when the buffer was enqueued. No new file descriptor is created at dequeue time and the value is only for the application convenience. When the multi-planar API is used the m.fd fields of the passed array of struct v4l2_plane are filled instead.
By default VIDIOC_DQBUF blocks when no buffer is in the outgoing queue. When the O_NONBLOCK flag was given to the open() function, VIDIOC_DQBUF returns immediately with an EAGAIN error code when no buffer is available.
The struct v4l2_buffer structure is specified in buffer.
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.
-
EAGAIN
Non-blocking I/O has been selected using
O_NONBLOCKand no buffer was in the outgoing queue. -
EINVAL
The buffer
typeis not supported, or theindexis out of bounds, or no buffers have been allocated yet, or theuserptrorlengthare invalid, or theV4L2_BUF_FLAG_REQUEST_FDflag was set but the givenrequest_fdwas invalid, orm.fdwas an invalid DMABUF file descriptor. -
EIO
VIDIOC_DQBUFfailed due to an internal error. Can also indicate temporary problems like signal loss. -
EPIPE
VIDIOC_DQBUFreturns this on an empty capture queue for mem2mem codecs if a buffer with theV4L2_BUF_FLAG_LASTwas already dequeued and no new buffers are expected to become available. -
EBADR
The
V4L2_BUF_FLAG_REQUEST_FDflag was set but the device does not support requests for the given buffer type, or theV4L2_BUF_FLAG_REQUEST_FDflag was not set but the device requires that the buffer is part of a request. -
EBUSY
The first buffer was queued via a request, but the application now tries to queue it directly, or vice versa (it is not permitted to mix the two APIs).
ioctl VIDIOC_QUERY_DV_TIMINGS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_QUERY_DV_TIMINGS - VIDIOC_SUBDEV_QUERY_DV_TIMINGS - Sense the DV preset received by the current input
Synopsis #
int ioctl(int fd, VIDIOC_QUERY_DV_TIMINGS, struct v4l2_dv_timings *argp)
int ioctl(int fd, VIDIOC_SUBDEV_QUERY_DV_TIMINGS, struct v4l2_dv_timings *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_dv_timings.
Description #
The hardware may be able to detect the current DV timings automatically, similar to sensing the video standard. To do so, applications call ioctl VIDIOC_QUERY_DV_TIMINGS with a pointer to a struct v4l2_dv_timings. Once the hardware detects the timings, it will fill in the timings structure.
If the timings could not be detected because there was no signal, then ENOLINK is returned. If a signal was detected, but it was unstable and the receiver could not lock to the signal, then ENOLCK is returned. If the receiver could lock to the signal, but the format is unsupported (e.g. because the pixelclock is out of range of the hardware capabilities), then the driver fills in whatever timings it could find and returns ERANGE. In that case the application can call ioctl VIDIOC_DV_TIMINGS_CAP, VIDIOC_SUBDEV_DV_TIMINGS_CAP to compare the found timings with the hardware's capabilities in order to give more precise feedback to the user.
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.
-
ENODATA
Digital video timings are not supported for this input or output.
-
ENOLINK
No timings could be detected because no signal was found.
-
ENOLCK
The signal was unstable and the hardware could not lock on to it.
-
ERANGE
Timings were found, but they are out of range of the hardware capabilities.
ioctl VIDIOC_QUERYBUF
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_QUERYBUF - Query the status of a buffer
Synopsis #
int ioctl(int fd, VIDIOC_QUERYBUF, struct v4l2_buffer *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_buffer.
Description #
This ioctl is part of the streaming I/O method. It can be used to query the status of a buffer at any time after buffers have been allocated with the vidioc_reqbufs ioctl.
Applications set the type field of a struct v4l2_buffer to the same buffer type as was previously used with struct v4l2_format type and struct v4l2_requestbuffers type, and the index field. Valid index numbers range from zero to the number of buffers allocated with vidioc_reqbufs (struct v4l2_requestbuffers count) minus one. The reserved and reserved2 fields must be set to 0. When using the multi-planar API, the m.planes field must contain a userspace pointer to an array of struct v4l2_plane and the length field has to be set to the number of elements in that array. After calling ioctl VIDIOC_QUERYBUF with a pointer to this structure drivers return an error code or fill the rest of the structure.
In the flags field the V4L2_BUF_FLAG_MAPPED, V4L2_BUF_FLAG_PREPARED, V4L2_BUF_FLAG_QUEUED and V4L2_BUF_FLAG_DONE flags will be valid. The memory field will be set to the current I/O method. For the single-planar API, the m.offset contains the offset of the buffer from the start of the device memory, the length field its size. For the multi-planar API, fields m.mem_offset and length in the m.planes array elements will be used instead and the length field of struct v4l2_buffer is set to the number of filled-in array elements. The driver may or may not set the remaining fields and flags, they are meaningless in this context.
The struct v4l2_buffer structure is specified in buffer.
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.
-
EINVAL
The buffer
typeis not supported, or theindexis out of bounds.
ioctl VIDIOC_QUERYCAP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_QUERYCAP - Query device capabilities
Synopsis #
int ioctl(int fd, VIDIOC_QUERYCAP, struct v4l2_capability *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_capability.
Description #
All V4L2 devices support the VIDIOC_QUERYCAP ioctl. It is used to identify kernel devices compatible with this specification and to obtain information about driver and hardware capabilities. The ioctl takes a pointer to a struct v4l2_capability which is filled by the driver. When the driver is not compatible with this specification the ioctl returns an EINVAL error code.
v4l2_capability
|
__u8 |
|
Name of the driver, a unique NUL-terminated ASCII string. For example: "bttv". Driver specific applications can use this information to verify the driver identity. It is also useful to work around known bugs, or to identify drivers in error reports. Storing strings in fixed sized arrays is bad practice but unavoidable here. Drivers and applications should take precautions to never read or write beyond the end of the array and to make sure the strings are properly NUL-terminated. |
|
__u8 |
|
Name of the device, a NUL-terminated UTF-8 string. For example: "Yoyodyne TV/FM". One driver may support different brands or models of video hardware. This information is intended for users, for example in a menu of available devices. Since multiple TV cards of the same brand may be installed which are supported by the same driver, this name should be combined with the character device file name (e. g. |
|
__u8 |
|
Location of the device in the system, a NUL-terminated ASCII string. For example: "PCI:0000:05:06.0". This information is intended for users, to distinguish multiple identical devices. If no such information is available the field must simply count the devices controlled by the driver ("platform:vivid-000"). The bus_info must start with "PCI:" for PCI boards, "PCIe:" for PCI Express boards, "usb-" for USB devices, "I2C:" for i2c devices, "ISA:" for ISA devices, "parport" for parallel port devices and "platform:" for platform devices. |
|
__u32 |
|
Version number of the driver. Starting with kernel 3.1, the version reported is provided by the V4L2 subsystem following the kernel numbering scheme. However, it may not always return the same version as the kernel if, for example, a stable or distribution-modified kernel uses the V4L2 stack from a newer kernel. The version number is formatted using the |
|
|
||
|
__u32 |
|
Available capabilities of the physical device as a whole, see device-capabilities. The same physical device can export multiple devices in /dev (e.g. /dev/videoX, /dev/vbiY and /dev/radioZ). The |
|
__u32 |
|
Device capabilities of the opened device, see device-capabilities. Should contain the available capabilities of that specific device node. So, for example, |
|
__u32 |
|
Reserved for future extensions. Drivers must set this array to zero. |
|
|
0x00000001 |
The device supports the single-planar API through the Video Capture interface. |
|
|
0x00001000 |
The device supports the multi-planar API through the Video Capture interface. |
|
|
0x00000002 |
The device supports the single-planar API through the Video Output interface. |
|
|
0x00002000 |
The device supports the multi-planar API through the Video Output interface. |
|
|
0x00008000 |
The device supports the single-planar API through the Video Memory-To-Memory interface. |
|
|
0x00004000 |
The device supports the multi-planar API through the Video Memory-To-Memory interface. |
|
|
0x00000004 |
The device supports the Video Overlay interface. A video overlay device typically stores captured images directly in the video memory of a graphics card, with hardware clipping and scaling. |
|
|
0x00000010 |
The device supports the Raw VBI Capture interface, providing Teletext and Closed Caption data. |
|
|
0x00000020 |
The device supports the Raw VBI Output interface. |
|
|
0x00000040 |
The device supports the Sliced VBI Capture interface. |
|
|
0x00000080 |
The device supports the Sliced VBI Output interface. |
|
|
0x00000100 |
The device supports the RDS capture interface. |
|
|
0x00000200 |
The device supports the Video Output Overlay (OSD) interface. Unlike the Video Overlay interface, this is a secondary function of video output devices and overlays an image onto an outgoing video signal. When the driver sets this flag, it must clear the |
|
|
0x00000400 |
The device supports the ioctl VIDIOC_S_HW_FREQ_SEEK ioctl for hardware frequency seeking. |
|
|
0x00000800 |
The device supports the RDS output interface. |
|
|
0x00010000 |
The device has some sort of tuner to receive RF-modulated video signals. For more information about tuner programming see Tuners and Modulators. |
|
|
0x00020000 |
The device has audio inputs or outputs. It may or may not support audio recording or playback, in PCM or compressed formats. PCM audio support must be implemented as ALSA or OSS interface. For more information on audio inputs and outputs see Audio Inputs and Outputs. |
|
|
0x00040000 |
This is a radio receiver. |
|
|
0x00080000 |
The device has some sort of modulator to emit RF-modulated video/audio signals. For more information about modulator programming see Tuners and Modulators. |
|
|
0x00100000 |
The device supports the SDR Capture interface. |
|
|
0x00200000 |
The device supports the struct |
|
|
0x00400000 |
The device supports the SDR Output interface. |
|
|
0x00800000 |
The device supports the Metadata Interface capture interface. |
|
|
0x01000000 |
The device supports the |
|
|
0x02000000 |
The device stores the EDID for a video input, or retrieves the EDID for a video output. It is a standalone EDID device, so no video streaming etc. will take place. For a video input this is typically an eeprom that supports the VESA Enhanced Display Data Channel Standard. It can be something else as well, for example a micro controller. For a video output this is typically read from an external device such as an HDMI splitter accessed by a serial port. |
|
|
0x04000000 |
The device supports the streaming I/O method. |
|
|
0x08000000 |
The device supports the Metadata Interface output interface. |
|
|
0x10000000 |
This is a touch device. |
|
|
0x20000000 |
There is only one input and/or output seen from userspace. The whole video topology configuration, including which I/O entity is routed to the input/output, is configured by userspace via the Media Controller. See Part IV - Media Controller API. |
|
|
0x80000000 |
The driver fills the |
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.
[1] The struct v4l2_framebuffer lacks an enum v4l2_buf_type field, therefore the type of overlay is implied by the driver capabilities.
ioctls VIDIOC_QUERYCTRL, VIDIOC_QUERY_EXT_CTRL and VIDIOC_QUERYMENU
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_QUERYCTRL - VIDIOC_QUERY_EXT_CTRL - VIDIOC_QUERYMENU - Enumerate controls and menu control items
Synopsis #
int ioctl(int fd, int VIDIOC_QUERYCTRL, struct v4l2_queryctrl *argp)
int ioctl(int fd, VIDIOC_QUERY_EXT_CTRL, struct v4l2_query_ext_ctrl *argp)
int ioctl(int fd, VIDIOC_QUERYMENU, struct v4l2_querymenu *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_queryctrl,v4l2_query_ext_ctrlorv4l2_querymenu(depending on the ioctl).
Description #
To query the attributes of a control applications set the id field of a struct v4l2_queryctrl and call the VIDIOC_QUERYCTRL ioctl with a pointer to this structure. The driver fills the rest of the structure or returns an EINVAL error code when the id is invalid.
It is possible to enumerate controls by calling VIDIOC_QUERYCTRL with successive id values starting from V4L2_CID_BASE up to and exclusive V4L2_CID_LASTP1. Drivers may return EINVAL if a control in this range is not supported. Further applications can enumerate private controls, which are not defined in this specification, by starting at V4L2_CID_PRIVATE_BASE and incrementing id until the driver returns EINVAL.
In both cases, when the driver sets the V4L2_CTRL_FLAG_DISABLED flag in the flags field this control is permanently disabled and should be ignored by the application. 1
When the application ORs id with V4L2_CTRL_FLAG_NEXT_CTRL the driver returns the next supported non-compound control, or EINVAL if there is none. In addition, the V4L2_CTRL_FLAG_NEXT_COMPOUND flag can be specified to enumerate all compound controls (i.e. controls with type ≥ V4L2_CTRL_COMPOUND_TYPES and/or array control, in other words controls that contain more than one value). Specify both V4L2_CTRL_FLAG_NEXT_CTRL and V4L2_CTRL_FLAG_NEXT_COMPOUND in order to enumerate all controls, compound or not. Drivers which do not support these flags yet always return EINVAL.
The VIDIOC_QUERY_EXT_CTRL ioctl was introduced in order to better support controls that can use compound types, and to expose additional control information that cannot be returned in struct v4l2_queryctrl since that structure is full.
VIDIOC_QUERY_EXT_CTRL is used in the same way as VIDIOC_QUERYCTRL, except that the reserved array must be zeroed as well.
Additional information is required for menu controls: the names of the menu items. To query them applications set the id and index fields of struct v4l2_querymenu and call the VIDIOC_QUERYMENU ioctl with a pointer to this structure. The driver fills the rest of the structure or returns an EINVAL error code when the id or index is invalid. Menu items are enumerated by calling VIDIOC_QUERYMENU with successive index values from struct v4l2_queryctrl minimum to maximum, inclusive.
See also the examples in control.
v4l2_queryctrl
|
__u32 |
|
Identifies the control, set by the application. See control-id for predefined IDs. When the ID is ORed with V4L2_CTRL_FLAG_NEXT_CTRL the driver clears the flag and returns the first control with a higher ID. Drivers which do not support this flag yet always return an |
|
__u32 |
|
Type of control, see |
|
__u8 |
|
Name of the control, a NUL-terminated ASCII string. This information is intended for the user. |
|
__s32 |
|
Minimum value, inclusive. This field gives a lower bound for the control. See enum |
|
__s32 |
|
Maximum value, inclusive. This field gives an upper bound for the control. See enum |
|
__s32 |
|
This field gives a step size for the control. See enum Generally drivers should not scale hardware control values. It may be necessary for example when the This field gives the smallest change of an integer control actually affecting hardware. Often the information is needed when the user can change controls by keyboard or GUI buttons, rather than a slider. When for example a hardware register accepts values 0-511 and the driver reports 0-65535, step should be 128. Note that although signed, the step value is supposed to be always positive. |
|
__s32 |
|
The default value of a |
|
__u32 |
|
Control flags, see control-flags. |
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
v4l2_query_ext_ctrl
|
__u32 |
|
Identifies the control, set by the application. See control-id for predefined IDs. When the ID is ORed with |
|
__u32 |
|
Type of control, see |
|
char |
|
Name of the control, a NUL-terminated ASCII string. This information is intended for the user. |
|
__s64 |
|
Minimum value, inclusive. This field gives a lower bound for the control. See enum |
|
__s64 |
|
Maximum value, inclusive. This field gives an upper bound for the control. See enum |
|
__u64 |
|
This field gives a step size for the control. See enum Generally drivers should not scale hardware control values. It may be necessary for example when the This field gives the smallest change of an integer control actually affecting hardware. Often the information is needed when the user can change controls by keyboard or GUI buttons, rather than a slider. When for example a hardware register accepts values 0-511 and the driver reports 0-65535, step should be 128. |
|
__s64 |
|
The default value of a |
|
__u32 |
|
Control flags, see control-flags. |
|
__u32 |
|
The size in bytes of a single element of the array. Given a char pointer |
|
__u32 |
|
The number of elements in the N-dimensional array. If this control is not an array, then |
|
__u32 |
|
The number of dimension in the N-dimensional array. If this control is not an array, then this field is 0. |
|
__u32 |
|
The size of each dimension. The first |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
v4l2_querymenu
|
__u32 |
|
Identifies the control, set by the application from the respective struct v4l2_queryctrl |
|
__u32 |
|
Index of the menu item, starting at zero, set by the application. |
|
union { |
(anonymous) |
|
|
__u8 |
|
Name of the menu item, a NUL-terminated ASCII string. This information is intended for the user. This field is valid for |
|
__s64 |
|
Value of the integer menu item. This field is valid for |
|
} |
||
|
__u32 |
|
Reserved for future extensions. Drivers must set the array to zero. |
v4l2_ctrl_type
|
Type |
|
|
|
Description |
|---|---|---|---|---|
|
|
any |
any |
any |
An integer-valued control ranging from minimum to maximum inclusive. The step value indicates the increment between values. |
|
|
0 |
1 |
1 |
A boolean-valued control. Zero corresponds to "disabled", and one means "enabled". |
|
|
≥ 0 |
1 |
N-1 |
The control has a menu of N choices. The names of the menu items can be enumerated with the |
|
|
≥ 0 |
1 |
N-1 |
The control has a menu of N choices. The values of the menu items can be enumerated with the |
|
|
0 |
n/a |
any |
A bitmask field. The maximum value is the set of bits that can be used, all other bits are to be 0. The maximum value is interpreted as a __u32, allowing the use of bit 31 in the bitmask. |
|
|
0 |
0 |
0 |
A control which performs an action when set. Drivers must ignore the value passed with |
|
|
any |
any |
any |
A 64-bit integer valued control. Minimum, maximum and step size cannot be queried using |
|
|
≥ 0 |
≥ 1 |
≥ 0 |
The minimum and maximum string lengths. The step size means that the string must be (minimum + N * step) characters long for N ≥ 0. These lengths do not include the terminating zero, so in order to pass a string of length 8 to VIDIOC_S_EXT_CTRLS you need to set the |
|
|
n/a |
n/a |
n/a |
This is not a control. When |
|
|
any |
any |
any |
An unsigned 8-bit valued control ranging from minimum to maximum inclusive. The step value indicates the increment between values. |
|
|
any |
any |
any |
An unsigned 16-bit valued control ranging from minimum to maximum inclusive. The step value indicates the increment between values. |
|
|
any |
any |
any |
An unsigned 32-bit valued control ranging from minimum to maximum inclusive. The step value indicates the increment between values. |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
n/a |
n/a |
n/a |
A struct |
|
|
0x0001 |
This control is permanently disabled and should be ignored by the application. Any attempt to change the control will result in an |
|
|
0x0002 |
This control is temporarily unchangeable, for example because another application took over control of the respective resource. Such controls may be displayed specially in a user interface. Attempts to change the control may result in an |
|
|
0x0004 |
This control is permanently readable only. Any attempt to change the control will result in an |
|
|
0x0008 |
A hint that changing this control may affect the value of other controls within the same control class. Applications should update their user interface accordingly. |
|
|
0x0010 |
This control is not applicable to the current configuration and should be displayed accordingly in a user interface. For example the flag may be set on a MPEG audio level 2 bitrate control when MPEG audio encoding level 1 was selected with another control. |
|
|
0x0020 |
A hint that this control is best represented as a slider-like element in a user interface. |
|
|
0x0040 |
This control is permanently writable only. Any attempt to read the control will result in an |
|
|
0x0080 |
This control is volatile, which means that the value of the control changes continuously. A typical example would be the current gain value if the device is in auto-gain mode. In such a case the hardware calculates the gain value based on the lighting conditions which can change over time. |
|
|
0x0100 |
This control has a pointer type, so its value has to be accessed using one of the pointer fields of struct |
|
|
0x0200 |
The value provided to the control will be propagated to the driver even if it remains constant. This is required when the control represents an action on the hardware. For example: clearing an error flag or triggering the flash. All the controls of the type |
|
|
0x0400 |
Changing this control value may modify the layout of the buffer (for video devices) or the media bus format (for sub-devices). A typical example would be the Note that typically controls with this flag will also set the |
|
|
0x0800 |
This control is a dynamically sized 1-dimensional array. It behaves the same as a regular array, except that the number of elements as reported by the |
|
|
0x1000 |
This control supports getting minimum and maximum values using vidioc_g_ext_ctrls with V4L2_CTRL_WHICH_MIN/MAX_VAL. |
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.
-
EINVAL
The struct v4l2_queryctrl
idis invalid. The struct v4l2_querymenuidis invalid orindexis out of range (less thanminimumor greater thanmaximum) or this particular menu item is not supported by the driver. -
EACCES
An attempt was made to read a write-only control.
[1] V4L2_CTRL_FLAG_DISABLED was intended for two purposes: Drivers can skip predefined controls not supported by the hardware (although returning EINVAL would do as well), or disable predefined and private controls after hardware detection without the trouble of reordering control arrays and indices (EINVAL cannot be used to skip private controls because it would prematurely end the enumeration).
ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_QUERYSTD - VIDIOC_SUBDEV_QUERYSTD - Sense the video standard received by the current input
Synopsis #
int ioctl(int fd, VIDIOC_QUERYSTD, v4l2_std_id *argp)
int ioctl(int fd, VIDIOC_SUBDEV_QUERYSTD, v4l2_std_id *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to
v4l2_std_id.
Description #
The hardware may be able to detect the current video standard automatically. To do so, applications call ioctl VIDIOC_QUERYSTD, VIDIOC_SUBDEV_QUERYSTD with a pointer to a v4l2_std_id type. The driver stores here a set of candidates, this can be a single flag or a set of supported standards if for example the hardware can only distinguish between 50 and 60 Hz systems. If no signal was detected, then the driver will return V4L2_STD_UNKNOWN. When detection is not possible or fails, the set must contain all standards supported by the current video input or output.
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.
-
ENODATA
Standard video timings are not supported for this input or output.
ioctl VIDIOC_REMOVE_BUFS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_REMOVE_BUFS - Removes buffers from a queue
Synopsis #
int ioctl(int fd, VIDIOC_REMOVE_BUFS, struct v4l2_remove_buffers *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_remove_buffers.
Description #
Applications can optionally call the ioctl VIDIOC_REMOVE_BUFS ioctl to remove buffers from a queue. ioctl VIDIOC_CREATE_BUFS ioctl support is mandatory to enable ioctl VIDIOC_REMOVE_BUFS. This ioctl is available if the V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS capability is set on the queue when VIDIOC_REQBUFS() or VIDIOC_CREATE_BUFS() are invoked.
v4l2_remove_buffers
|
__u32 |
|
The starting buffer index to remove. This field is ignored if count == 0. |
|
__u32 |
|
The number of buffers to be removed with indices 'index' until 'index + count - 1'. All buffers in this range must be valid and in DEQUEUED state. ioctl VIDIOC_REMOVE_BUFS will always check the validity of |
|
__u32 |
|
Type of the stream or buffers, this is the same as the struct |
|
__u32 |
|
A place holder for future extensions. Drivers and applications must set the array to zero. |
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. If an error occurs, no buffers will be freed and one of the error codes below will be returned:
-
EBUSY
File I/O is in progress. One or more of the buffers in the range
indextoindex + count - 1are not in DEQUEUED state. -
EINVAL
One or more of the buffers in the range
indextoindex + count - 1do not exist in the queue. The buffer type (typefield) is not valid.
ioctl VIDIOC_REQBUFS
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_REQBUFS - Initiate Memory Mapping, User Pointer I/O or DMA buffer I/O
Synopsis #
int ioctl(int fd, VIDIOC_REQBUFS, struct v4l2_requestbuffers *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_requestbuffers.
Description #
This ioctl is used to initiate memory mapped, user pointer or DMABUF based I/O. Memory mapped buffers are located in device memory and must be allocated with this ioctl before they can be mapped into the application's address space. User buffers are allocated by applications themselves, and this ioctl is merely used to switch the driver into user pointer I/O mode and to setup some internal structures. Similarly, DMABUF buffers are allocated by applications through a device driver, and this ioctl only configures the driver into DMABUF I/O mode without performing any direct allocation.
To allocate device buffers applications initialize all fields of the struct v4l2_requestbuffers structure. They set the type field to the respective stream or buffer type, the count field to the desired number of buffers, memory must be set to the requested I/O method and the reserved array must be zeroed. When the ioctl is called with a pointer to this structure the driver will attempt to allocate the requested number of buffers and it stores the actual number allocated in the count field. It can be smaller than the number requested, even zero, when the driver runs out of free memory. A larger number is also possible when the driver requires more buffers to function correctly. For example video output requires at least two buffers, one displayed and one filled by the application.
When the I/O method is not supported the ioctl returns an EINVAL error code.
Applications can call ioctl VIDIOC_REQBUFS again to change the number of buffers. Note that if any buffers are still mapped or exported via DMABUF, then ioctl VIDIOC_REQBUFS can only succeed if the V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS capability is set. Otherwise ioctl VIDIOC_REQBUFS will return the EBUSY error code. If V4L2_BUF_CAP_SUPPORTS_ORPHANED_BUFS is set, then these buffers are orphaned and will be freed when they are unmapped or when the exported DMABUF fds are closed. A count value of zero frees or orphans all buffers, after aborting or finishing any DMA in progress, an implicit VIDIOC_STREAMOFF.
v4l2_requestbuffers
|
__u32 |
|
The number of buffers requested or granted. |
|
__u32 |
|
Type of the stream or buffers, this is the same as the struct |
|
__u32 |
|
Applications set this field to |
|
__u32 |
|
Set by the driver. If 0, then the driver doesn't support capabilities. In that case all you know is that the driver is guaranteed to support If you want to query the capabilities with a minimum of side-effects, then this can be called with |
|
__u8 |
|
Specifies additional buffer management attributes. See memory-flags. |
|
__u8 |
|
Reserved for future extensions. |
|
|
0x00000001 |
This buffer type supports the |
|
|
0x00000002 |
This buffer type supports the |
|
|
0x00000004 |
This buffer type supports the |
|
|
0x00000008 |
This buffer type supports requests. |
|
|
0x00000010 |
The kernel allows calling ioctl VIDIOC_REQBUFS while buffers are still mapped or exported via DMABUF. These orphaned buffers will be freed when they are unmapped or when the exported DMABUF fds are closed. |
|
|
0x00000020 |
Only valid for stateless decoders. If set, then userspace can set the |
|
|
0x00000040 |
This capability is set by the driver to indicate that the queue supports cache and memory management hints. However, it's only valid when the queue is used for memory mapping streaming I/O. See V4L2_BUF_FLAG_NO_CACHE_INVALIDATE, V4L2_BUF_FLAG_NO_CACHE_CLEAN and V4L2_MEMORY_FLAG_NON_COHERENT. |
|
|
0x00000080 |
If set, then the |
|
|
0x00000100 |
If set, then |
|
|
0x00000001 |
A buffer is allocated either in coherent (it will be automatically coherent between the CPU and the bus) or non-coherent memory. The latter can provide performance gains, for instance the CPU cache sync/flush operations can be avoided if the buffer is accessed by the corresponding device only and the CPU does not read/write to/from that buffer. However, this requires extra care from the driver -- it must guarantee memory consistency by issuing a cache flush/sync when consistency is needed. If this flag is set V4L2 will attempt to allocate the buffer in non-coherent memory. The flag takes effect only if the buffer is used for memory mapping I/O and the queue reports the V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS capability. |
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.
-
EINVAL
The buffer type (
typefield) or the requested I/O method (memory) is not supported.
ioctl VIDIOC_S_HW_FREQ_SEEK
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_S_HW_FREQ_SEEK - Perform a hardware frequency seek
Synopsis #
int ioctl(int fd, VIDIOC_S_HW_FREQ_SEEK, struct v4l2_hw_freq_seek *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_hw_freq_seek.
Description #
Start a hardware frequency seek from the current frequency. To do this applications initialize the tuner, type, seek_upward, wrap_around, spacing, rangelow and rangehigh fields, and zero out the reserved array of a struct v4l2_hw_freq_seek and call the VIDIOC_S_HW_FREQ_SEEK ioctl with a pointer to this structure.
The rangelow and rangehigh fields can be set to a non-zero value to tell the driver to search a specific band. If the struct v4l2_tuner capability field has the V4L2_TUNER_CAP_HWSEEK_PROG_LIM flag set, these values must fall within one of the bands returned by ioctl VIDIOC_ENUM_FREQ_BANDS. If the V4L2_TUNER_CAP_HWSEEK_PROG_LIM flag is not set, then these values must exactly match those of one of the bands returned by ioctl VIDIOC_ENUM_FREQ_BANDS. If the current frequency of the tuner does not fall within the selected band it will be clamped to fit in the band before the seek is started.
If an error is returned, then the original frequency will be restored.
This ioctl is supported if the V4L2_CAP_HW_FREQ_SEEK capability is set.
If this ioctl is called from a non-blocking filehandle, then EAGAIN error code is returned and no seek takes place.
v4l2_hw_freq_seek
|
__u32 |
|
The tuner index number. This is the same value as in the struct |
|
__u32 |
|
The tuner type. This is the same value as in the struct |
|
__u32 |
|
If non-zero, seek upward from the current frequency, else seek downward. |
|
__u32 |
|
If non-zero, wrap around when at the end of the frequency range, else stop seeking. The struct |
|
__u32 |
|
If non-zero, defines the hardware seek resolution in Hz. The driver selects the nearest value that is supported by the device. If spacing is zero a reasonable default value is used. |
|
__u32 |
|
If non-zero, the lowest tunable frequency of the band to search in units of 62.5 kHz, or if the struct |
|
__u32 |
|
If non-zero, the highest tunable frequency of the band to search in units of 62.5 kHz, or if the struct |
|
__u32 |
|
Reserved for future extensions. Applications must set the array to zero. |
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.
-
EINVAL
The
tunerindex is out of bounds, thewrap_aroundvalue is not supported or one of the values in thetype,rangeloworrangehighfields is wrong. -
EAGAIN
Attempted to call
VIDIOC_S_HW_FREQ_SEEKwith the filehandle in non-blocking mode. -
ENODATA
The hardware seek found no channels.
-
EBUSY
Another hardware seek is already in progress.
ioctl VIDIOC_STREAMON, VIDIOC_STREAMOFF
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_STREAMON - VIDIOC_STREAMOFF - Start or stop streaming I/O
Synopsis #
int ioctl(int fd, VIDIOC_STREAMON, const int *argp)
int ioctl(int fd, VIDIOC_STREAMOFF, const int *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to an integer.
Description #
The VIDIOC_STREAMON and VIDIOC_STREAMOFF ioctl start and stop the capture or output process during streaming (memory mapping, user pointer or DMABUF) I/O.
Capture hardware is disabled and no input buffers are filled (if there are any empty buffers in the incoming queue) until VIDIOC_STREAMON has been called. Output hardware is disabled and no video signal is produced until VIDIOC_STREAMON has been called.
Memory-to-memory devices will not start until VIDIOC_STREAMON has been called for both the capture and output stream types.
If VIDIOC_STREAMON fails then any already queued buffers will remain queued.
The VIDIOC_STREAMOFF ioctl, apart of aborting or finishing any DMA in progress, unlocks any user pointer buffers locked in physical memory, and it removes all buffers from the incoming and outgoing queues. That means all images captured but not dequeued yet will be lost, likewise all images enqueued for output but not transmitted yet. I/O returns to the same state as after calling vidioc_reqbufs and can be restarted accordingly.
If buffers have been queued with ioctl VIDIOC_QBUF, VIDIOC_DQBUF and VIDIOC_STREAMOFF is called without ever having called VIDIOC_STREAMON, then those queued buffers will also be removed from the incoming queue and all are returned to the same state as after calling vidioc_reqbufs and can be restarted accordingly.
Both ioctls take a pointer to an integer, the desired buffer or stream type. This is the same as struct v4l2_requestbuffers type.
If VIDIOC_STREAMON is called when streaming is already in progress, or if VIDIOC_STREAMOFF is called when streaming is already stopped, then 0 is returned. Nothing happens in the case of VIDIOC_STREAMON, but VIDIOC_STREAMOFF will return queued buffers to their starting state as mentioned above.
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.
-
EINVAL
The buffer
typeis not supported, or no buffers have been allocated (memory mapping) or enqueued (output) yet. -
EPIPE
The driver implements pad-level format configuration and the pipeline configuration is invalid.
-
ENOLINK
The driver implements Media Controller interface and the pipeline link configuration is invalid.
ioctl VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL - Enumerate frame intervals
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL, struct v4l2_subdev_frame_interval_enum * argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_frame_interval_enum.
Description #
This ioctl lets applications enumerate available frame intervals on a given sub-device pad. Frame intervals only makes sense for sub-devices that can control the frame period on their own. This includes, for instance, image sensors and TV tuners.
For the common use case of image sensors, the frame intervals available on the sub-device output pad depend on the frame format and size on the same pad. Applications must thus specify the desired format and size when enumerating frame intervals.
To enumerate frame intervals applications initialize the index, pad, which, code, width and height fields of struct v4l2_subdev_frame_interval_enum and call the ioctl VIDIOC_SUBDEV_ENUM_FRAME_INTERVAL ioctl with a pointer to this structure. Drivers fill the rest of the structure or return an EINVAL error code if one of the input fields is invalid. All frame intervals are enumerable by beginning at index zero and incrementing by one until EINVAL is returned.
Available frame intervals may depend on the current 'try' formats at other pads of the sub-device, as well as on the current active links. See ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT for more information about the try formats.
Sub-devices that support the frame interval enumeration ioctl should implemented it on a single pad only. Its behaviour when supported on multiple pads of the same sub-device is not defined.
v4l2_subdev_frame_interval_enum
|
__u32 |
|
Number of the format in the enumeration, set by the application. |
|
__u32 |
|
Pad number as reported by the media controller API. |
|
__u32 |
|
The media bus format code, as defined in v4l2-mbus-format. |
|
__u32 |
|
Frame width, in pixels. |
|
__u32 |
|
Frame height, in pixels. |
|
struct |
|
Period, in seconds, between consecutive video frames. |
|
__u32 |
|
Frame intervals to be enumerated, from enum v4l2_subdev_format_whence. |
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
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.
-
EINVAL
The struct
v4l2_subdev_frame_interval_enumpadreferences a non-existing pad, thewhichfield has an unsupported value, one of thecode,widthorheightfields are invalid for the given pad, or theindexfield is out of bounds.
ioctl VIDIOC_SUBDEV_ENUM_FRAME_SIZE
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_ENUM_FRAME_SIZE - Enumerate media bus frame sizes
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_ENUM_FRAME_SIZE, struct v4l2_subdev_frame_size_enum * argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_frame_size_enum.
Description #
This ioctl allows applications to access the enumeration of frame sizes supported by a sub-device on the specified pad for the specified media bus format. Supported formats can be retrieved with the vidioc_subdev_enum_mbus_code ioctl.
The enumerations are defined by the driver, and indexed using the index field of the struct v4l2_subdev_frame_size_enum. Each pair of pad and code correspond to a separate enumeration. Each enumeration starts with the index of 0, and the lowest invalid index marks the end of the enumeration.
Therefore, to enumerate frame sizes allowed on the specified pad and using the specified mbus format, initialize the pad, which, and code fields to desired values, and set index to 0. Then call the ioctl VIDIOC_SUBDEV_ENUM_FRAME_SIZE ioctl with a pointer to the structure.
A successful call will return with minimum and maximum frame sizes filled in. Repeat with increasing index until EINVAL is received. EINVAL means that either no more entries are available in the enumeration, or that an input parameter was invalid.
Sub-devices that only support discrete frame sizes (such as most sensors) will return one or more frame sizes with identical minimum and maximum values.
Not all possible sizes in given [minimum, maximum] ranges need to be supported. For instance, a scaler that uses a fixed-point scaling ratio might not be able to produce every frame size between the minimum and maximum values. Applications must use the VIDIOC_SUBDEV_S_FMT ioctl to try the sub-device for an exact supported frame size.
Available frame sizes may depend on the current 'try' formats at other pads of the sub-device, as well as on the current active links and the current values of V4L2 controls. See ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT for more information about try formats.
v4l2_subdev_frame_size_enum
|
__u32 |
|
Index of the frame size in the enumeration belonging to the given pad and format. Filled in by the application. |
|
__u32 |
|
Pad number as reported by the media controller API. Filled in by the application. |
|
__u32 |
|
The media bus format code, as defined in v4l2-mbus-format. Filled in by the application. |
|
__u32 |
|
Minimum frame width, in pixels. Filled in by the driver. |
|
__u32 |
|
Maximum frame width, in pixels. Filled in by the driver. |
|
__u32 |
|
Minimum frame height, in pixels. Filled in by the driver. |
|
__u32 |
|
Maximum frame height, in pixels. Filled in by the driver. |
|
__u32 |
|
Frame sizes to be enumerated, from enum v4l2_subdev_format_whence. |
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
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.
-
EINVAL
The struct
v4l2_subdev_frame_size_enumpadreferences a non-existing pad, thewhichfield has an unsupported value, thecodeis invalid for the given pad, or theindexfield is out of bounds.
ioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_ENUM_MBUS_CODE - Enumerate media bus formats
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_ENUM_MBUS_CODE, struct v4l2_subdev_mbus_code_enum * argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_mbus_code_enum.
Description #
This call is used by the application to access the enumeration of media bus formats for the selected pad.
The enumerations are defined by the driver, and indexed using the index field of struct v4l2_subdev_mbus_code_enum. Each enumeration starts with the index of 0, and the lowest invalid index marks the end of enumeration.
Therefore, to enumerate media bus formats available at a given sub-device pad, initialize the pad, and which fields to desired values, and set index to 0. Then call the ioctl VIDIOC_SUBDEV_ENUM_MBUS_CODE ioctl with a pointer to this structure.
A successful call will return with the code field filled in with a mbus code value. Repeat with increasing index until EINVAL is received. EINVAL means that either pad is invalid, or that there are no more codes available at this pad.
The driver must not return the same value of code for different indices at the same pad.
Available media bus formats may depend on the current 'try' formats at other pads of the sub-device, as well as on the current active links. See vidioc_subdev_g_fmt for more information about the try formats.
v4l2_subdev_mbus_code_enum
|
__u32 |
|
Pad number as reported by the media controller API. Filled in by the application. |
|
__u32 |
|
Index of the mbus code in the enumeration belonging to the given pad. Filled in by the application. |
|
__u32 |
|
The media bus format code, as defined in Media Bus Formats. Filled in by the driver. |
|
__u32 |
|
Media bus format codes to be enumerated, from enum v4l2_subdev_format_whence. |
|
__u32 |
|
|
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
|
V4L2_SUBDEV_MBUS_CODE_CSC_COLORSPACE |
0x00000001 |
The driver allows the application to try to change the default colorspace encoding. The application can ask to configure the colorspace of the subdevice when calling the VIDIOC_SUBDEV_S_FMT ioctl with V4L2_MBUS_FRAMEFMT_SET_CSC set. See Media Bus Formats on how to do this. |
|
V4L2_SUBDEV_MBUS_CODE_CSC_XFER_FUNC |
0x00000002 |
The driver allows the application to try to change the default transform function. The application can ask to configure the transform function of the subdevice when calling the VIDIOC_SUBDEV_S_FMT ioctl with V4L2_MBUS_FRAMEFMT_SET_CSC set. See Media Bus Formats on how to do this. |
|
V4L2_SUBDEV_MBUS_CODE_CSC_YCBCR_ENC |
0x00000004 |
The driver allows the application to try to change the default Y'CbCr encoding. The application can ask to configure the Y'CbCr encoding of the subdevice when calling the VIDIOC_SUBDEV_S_FMT ioctl with V4L2_MBUS_FRAMEFMT_SET_CSC set. See Media Bus Formats on how to do this. |
|
V4L2_SUBDEV_MBUS_CODE_CSC_HSV_ENC |
0x00000004 |
The driver allows the application to try to change the default HSV encoding. The application can ask to configure the HSV encoding of the subdevice when calling the VIDIOC_SUBDEV_S_FMT ioctl with V4L2_MBUS_FRAMEFMT_SET_CSC set. See Media Bus Formats on how to do this. |
|
V4L2_SUBDEV_MBUS_CODE_CSC_QUANTIZATION |
0x00000008 |
The driver allows the application to try to change the default quantization. The application can ask to configure the quantization of the subdevice when calling the VIDIOC_SUBDEV_S_FMT ioctl with V4L2_MBUS_FRAMEFMT_SET_CSC set. See Media Bus Formats on how to do this. |
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.
-
EINVAL
The struct
v4l2_subdev_mbus_code_enumpadreferences a non-existing pad, thewhichfield has an unsupported value, or theindexfield is out of bounds.
ioctl VIDIOC_SUBDEV_G_CLIENT_CAP, VIDIOC_SUBDEV_S_CLIENT_CAP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_G_CLIENT_CAP - VIDIOC_SUBDEV_S_CLIENT_CAP - Get or set client capabilities.
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_G_CLIENT_CAP, struct v4l2_subdev_client_capability *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_CLIENT_CAP, struct v4l2_subdev_client_capability *argp)
Arguments #
-
fdFile descriptor returned by open().
-
argpPointer to struct
v4l2_subdev_client_capability.
Description #
These ioctls are used to get and set the client (the application using the subdevice ioctls) capabilities. The client capabilities are stored in the file handle of the opened subdev device node, and the client must set the capabilities for each opened subdev separately.
By default no client capabilities are set when a subdev device node is opened.
The purpose of the client capabilities are to inform the kernel of the behavior of the client, mainly related to maintaining compatibility with different kernel and userspace versions.
The VIDIOC_SUBDEV_G_CLIENT_CAP ioctl returns the current client capabilities associated with the file handle fd.
The VIDIOC_SUBDEV_S_CLIENT_CAP ioctl sets client capabilities for the file handle fd. The new capabilities fully replace the current capabilities, the ioctl can therefore also be used to remove capabilities that have previously been set.
VIDIOC_SUBDEV_S_CLIENT_CAP modifies the struct v4l2_subdev_client_capability to reflect the capabilities that have been accepted. A common case for the kernel not accepting a capability is that the kernel is older than the headers the userspace uses, and thus the capability is unknown to the kernel.
v4l2_subdev_client_capability
|
__u64 |
|
Sub-device client capabilities of the opened device. |
|
Capability |
Description |
|---|---|
|
|
The client is aware of streams. Setting this flag enables the use of 'stream' fields (referring to the stream number) with various ioctls. If this is not set (which is the default), the 'stream' fields will be forced to 0 by the kernel. |
|
|
The client is aware of the |
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.
-
ENOIOCTLCMD
The kernel does not support this ioctl.
ioctl VIDIOC_SUBDEV_G_CROP, VIDIOC_SUBDEV_S_CROP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_G_CROP - VIDIOC_SUBDEV_S_CROP - Get or set the crop rectangle on a subdev pad
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_G_CROP, struct v4l2_subdev_crop *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_CROP, const struct v4l2_subdev_crop *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_crop.
Description #
To retrieve the current crop rectangle applications set the pad field of a struct v4l2_subdev_crop to the desired pad number as reported by the media API and the which field to V4L2_SUBDEV_FORMAT_ACTIVE. They then call the VIDIOC_SUBDEV_G_CROP ioctl with a pointer to this structure. The driver fills the members of the rect field or returns EINVAL error code if the input arguments are invalid, or if cropping is not supported on the given pad.
To change the current crop rectangle applications set both the pad and which fields and all members of the rect field. They then call the VIDIOC_SUBDEV_S_CROP ioctl with a pointer to this structure. The driver verifies the requested crop rectangle, adjusts it based on the hardware capabilities and configures the device. Upon return the struct v4l2_subdev_crop contains the current format as would be returned by a VIDIOC_SUBDEV_G_CROP call.
Applications can query the device capabilities by setting the which to V4L2_SUBDEV_FORMAT_TRY. When set, 'try' crop rectangles are not applied to the device by the driver, but are mangled exactly as active crop rectangles and stored in the sub-device file handle. Two applications querying the same sub-device would thus not interact with each other.
If the subdev device node has been registered in read-only mode, calls to VIDIOC_SUBDEV_S_CROP are only valid if the which field is set to V4L2_SUBDEV_FORMAT_TRY, otherwise an error is returned and the errno variable is set to -EPERM.
Drivers must not return an error solely because the requested crop rectangle doesn't match the device capabilities. They must instead modify the rectangle to match what the hardware can provide. The modified format should be as close as possible to the original request.
v4l2_subdev_crop
|
__u32 |
|
Pad number as reported by the media framework. |
|
__u32 |
|
Crop rectangle to get or set, from enum v4l2_subdev_format_whence. |
|
struct |
|
Crop rectangle boundaries, in pixels. |
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
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.
-
EBUSY
The crop rectangle can't be changed because the pad is currently busy. This can be caused, for instance, by an active video stream on the pad. The ioctl must not be retried without performing another action to fix the problem first. Only returned by
VIDIOC_SUBDEV_S_CROP -
EINVAL
The struct
v4l2_subdev_croppadreferences a non-existing pad, thewhichfield has an unsupported value, or cropping is not supported on the given subdev pad. -
EPERM
The
VIDIOC_SUBDEV_S_CROPioctl has been called on a read-only subdevice and thewhichfield is set toV4L2_SUBDEV_FORMAT_ACTIVE.
ioctl VIDIOC_SUBDEV_G_FMT, VIDIOC_SUBDEV_S_FMT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_G_FMT - VIDIOC_SUBDEV_S_FMT - Get or set the data format on a subdev pad
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_G_FMT, struct v4l2_subdev_format *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_FMT, struct v4l2_subdev_format *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_format.
Description #
These ioctls are used to negotiate the frame format at specific subdev pads in the image pipeline.
To retrieve the current format applications set the pad field of a struct v4l2_subdev_format to the desired pad number as reported by the media API and the which field to V4L2_SUBDEV_FORMAT_ACTIVE. When they call the VIDIOC_SUBDEV_G_FMT ioctl with a pointer to this structure the driver fills the members of the format field.
To change the current format applications set both the pad and which fields and all members of the format field. When they call the VIDIOC_SUBDEV_S_FMT ioctl with a pointer to this structure the driver verifies the requested format, adjusts it based on the hardware capabilities and configures the device. Upon return the struct v4l2_subdev_format contains the current format as would be returned by a VIDIOC_SUBDEV_G_FMT call.
Applications can query the device capabilities by setting the which to V4L2_SUBDEV_FORMAT_TRY. When set, 'try' formats are not applied to the device by the driver, but are changed exactly as active formats and stored in the sub-device file handle. Two applications querying the same sub-device would thus not interact with each other.
For instance, to try a format at the output pad of a sub-device, applications would first set the try format at the sub-device input with the VIDIOC_SUBDEV_S_FMT ioctl. They would then either retrieve the default format at the output pad with the VIDIOC_SUBDEV_G_FMT ioctl, or set the desired output pad format with the VIDIOC_SUBDEV_S_FMT ioctl and check the returned value.
Try formats do not depend on active formats, but can depend on the current links configuration or sub-device controls value. For instance, a low-pass noise filter might crop pixels at the frame boundaries, modifying its output frame size.
If the subdev device node has been registered in read-only mode, calls to VIDIOC_SUBDEV_S_FMT are only valid if the which field is set to V4L2_SUBDEV_FORMAT_TRY, otherwise an error is returned and the errno variable is set to -EPERM.
Drivers must not return an error solely because the requested format doesn't match the device capabilities. They must instead modify the format to match what the hardware can provide. The modified format should be as close as possible to the original request.
v4l2_subdev_format
|
__u32 |
|
Pad number as reported by the media controller API. |
|
__u32 |
|
Format to modified, from enum v4l2_subdev_format_whence. |
|
struct |
|
Definition of an image format, see |
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
|
V4L2_SUBDEV_FORMAT_TRY |
0 |
Try formats, used for querying device capabilities. |
|
V4L2_SUBDEV_FORMAT_ACTIVE |
1 |
Active formats, applied to the hardware. |
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.
-
EBUSY
The format can't be changed because the pad is currently busy. This can be caused, for instance, by an active video stream on the pad. The ioctl must not be retried without performing another action to fix the problem first. Only returned by
VIDIOC_SUBDEV_S_FMT -
EINVAL
The struct
v4l2_subdev_formatpadreferences a non-existing pad, or thewhichfield has an unsupported value. -
EPERM
The
VIDIOC_SUBDEV_S_FMTioctl has been called on a read-only subdevice and thewhichfield is set toV4L2_SUBDEV_FORMAT_ACTIVE.
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.
ioctl VIDIOC_SUBDEV_G_FRAME_INTERVAL, VIDIOC_SUBDEV_S_FRAME_INTERVAL
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_G_FRAME_INTERVAL - VIDIOC_SUBDEV_S_FRAME_INTERVAL - Get or set the frame interval on a subdev pad
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_G_FRAME_INTERVAL, struct v4l2_subdev_frame_interval *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_FRAME_INTERVAL, struct v4l2_subdev_frame_interval *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_frame_interval.
Description #
These ioctls are used to get and set the frame interval at specific subdev pads in the image pipeline. The frame interval only makes sense for sub-devices that can control the frame period on their own. This includes, for instance, image sensors and TV tuners. Sub-devices that don't support frame intervals must not implement these ioctls.
To retrieve the current frame interval applications set the pad field of a struct v4l2_subdev_frame_interval to the desired pad number as reported by the media controller API. When they call the VIDIOC_SUBDEV_G_FRAME_INTERVAL ioctl with a pointer to this structure the driver fills the members of the interval field.
To change the current frame interval applications set both the pad field and all members of the interval field. When they call the VIDIOC_SUBDEV_S_FRAME_INTERVAL ioctl with a pointer to this structure the driver verifies the requested interval, adjusts it based on the hardware capabilities and configures the device. Upon return the struct v4l2_subdev_frame_interval contains the current frame interval as would be returned by a VIDIOC_SUBDEV_G_FRAME_INTERVAL call.
If the subdev device node has been registered in read-only mode, calls to VIDIOC_SUBDEV_S_FRAME_INTERVAL are only valid if the which field is set to V4L2_SUBDEV_FORMAT_TRY, otherwise an error is returned and the errno variable is set to -EPERM.
Drivers must not return an error solely because the requested interval doesn't match the device capabilities. They must instead modify the interval to match what the hardware can provide. The modified interval should be as close as possible to the original request.
Changing the frame interval shall never change the format. Changing the format, on the other hand, may change the frame interval.
Sub-devices that support the frame interval ioctls should implement them on a single pad only. Their behaviour when supported on multiple pads of the same sub-device is not defined.
v4l2_subdev_frame_interval
|
__u32 |
|
Pad number as reported by the media controller API. |
|
struct |
|
Period, in seconds, between consecutive video frames. |
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Active or try frame interval, from enum v4l2_subdev_format_whence. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
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.
-
EBUSY
The frame interval can't be changed because the pad is currently busy. This can be caused, for instance, by an active video stream on the pad. The ioctl must not be retried without performing another action to fix the problem first. Only returned by
VIDIOC_SUBDEV_S_FRAME_INTERVAL -
EINVAL
The struct
v4l2_subdev_frame_intervalpadreferences a non-existing pad, thewhichfield has an unsupported value, or the pad doesn't support frame intervals. -
EPERM
The
VIDIOC_SUBDEV_S_FRAME_INTERVALioctl has been called on a read-only subdevice and thewhichfield is set toV4L2_SUBDEV_FORMAT_ACTIVE.
ioctl VIDIOC_SUBDEV_G_ROUTING, VIDIOC_SUBDEV_S_ROUTING
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_G_ROUTING - VIDIOC_SUBDEV_S_ROUTING - Get or set routing between streams of media pads in a media entity.
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_G_ROUTING, struct v4l2_subdev_routing *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_ROUTING, struct v4l2_subdev_routing *argp)
Arguments #
-
fdFile descriptor returned by open().
-
argpPointer to struct
v4l2_subdev_routing.
Description #
These ioctls are used to get and set the routing in a media entity. The routing configuration determines the flows of data inside an entity.
Drivers report their current routing tables using the VIDIOC_SUBDEV_G_ROUTING ioctl and application may enable or disable routes with the VIDIOC_SUBDEV_S_ROUTING ioctl, by adding or removing routes and setting or clearing flags of the flags field of a struct v4l2_subdev_route. Similarly to VIDIOC_SUBDEV_G_ROUTING, also VIDIOC_SUBDEV_S_ROUTING returns the routes back to the user.
All stream configurations are reset when VIDIOC_SUBDEV_S_ROUTING is called. This means that the userspace must reconfigure all stream formats and selections after calling the ioctl with e.g. VIDIOC_SUBDEV_S_FMT.
Only subdevices which have both sink and source pads can support routing.
The len_routes field indicates the number of routes that can fit in the routes array allocated by userspace. It is set by applications for both ioctls to indicate how many routes the kernel can return, and is never modified by the kernel.
The num_routes field indicates the number of routes in the routing table. For VIDIOC_SUBDEV_S_ROUTING, it is set by userspace to the number of routes that the application stored in the routes array. For both ioctls, it is returned by the kernel and indicates how many routes are stored in the subdevice routing table. This may be smaller or larger than the value of num_routes set by the application for VIDIOC_SUBDEV_S_ROUTING, as drivers may adjust the requested routing table.
The kernel can return a num_routes value larger than len_routes from both ioctls. This indicates thare are more routes in the routing table than fits the routes array. In this case, the routes array is filled by the kernel with the first len_routes entries of the subdevice routing table. This is not considered to be an error, and the ioctl call succeeds. If the applications wants to retrieve the missing routes, it can issue a new VIDIOC_SUBDEV_G_ROUTING call with a large enough routes array.
VIDIOC_SUBDEV_S_ROUTING may return more routes than the user provided in num_routes field due to e.g. hardware properties.
v4l2_subdev_routing
|
__u32 |
|
Routing table to be accessed, from enum v4l2_subdev_format_whence. |
|
__u32 |
|
The length of the array (as in memory reserved for the array) |
|
struct |
|
Array of struct |
|
__u32 |
|
Number of entries of the routes array |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
v4l2_subdev_route
|
__u32 |
|
Sink pad number. |
|
__u32 |
|
Sink pad stream number. |
|
__u32 |
|
Source pad number. |
|
__u32 |
|
Source pad stream number. |
|
__u32 |
|
Route enable/disable flags v4l2_subdev_routing_flags. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
|
V4L2_SUBDEV_ROUTE_FL_ACTIVE |
0x0001 |
The route is enabled. Set by applications. |
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.
-
EINVAL
The sink or source pad identifiers reference a non-existing pad or reference pads of different types (ie. the sink_pad identifiers refers to a source pad), the
whichfield has an unsupported value, or, forVIDIOC_SUBDEV_S_ROUTING, the num_routes field set by the application is larger than the len_routes field value. -
ENXIO
The application requested routes cannot be created or the state of the specified routes cannot be modified. Only returned for
VIDIOC_SUBDEV_S_ROUTING. -
E2BIG
The application provided
num_routesforVIDIOC_SUBDEV_S_ROUTINGis larger than the number of routes the driver can handle.
ioctl VIDIOC_SUBDEV_G_SELECTION, VIDIOC_SUBDEV_S_SELECTION
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_G_SELECTION - VIDIOC_SUBDEV_S_SELECTION - Get or set selection rectangles on a subdev pad
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_G_SELECTION, struct v4l2_subdev_selection *argp)
int ioctl(int fd, VIDIOC_SUBDEV_S_SELECTION, struct v4l2_subdev_selection *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_selection.
Description #
The selections are used to configure various image processing functionality performed by the subdevs which affect the image size. This currently includes cropping, scaling and composition.
The selection API replaces the old subdev crop API. All the function of the crop API, and more, are supported by the selections API.
See subdev for more information on how each selection target affects the image processing pipeline inside the subdevice.
If the subdev device node has been registered in read-only mode, calls to VIDIOC_SUBDEV_S_SELECTION are only valid if the which field is set to V4L2_SUBDEV_FORMAT_TRY, otherwise an error is returned and the errno variable is set to -EPERM.
Types of selection targets #
There are two types of selection targets: actual and bounds. The actual targets are the targets which configure the hardware. The BOUNDS target will return a rectangle that contain all possible actual rectangles.
Discovering supported features #
To discover which targets are supported, the user can perform VIDIOC_SUBDEV_G_SELECTION on them. Any unsupported target will return EINVAL.
Selection targets and flags are documented in Common selection definitions.
v4l2_subdev_selection
|
__u32 |
|
Active or try selection, from enum v4l2_subdev_format_whence. |
|
__u32 |
|
Pad number as reported by the media framework. |
|
__u32 |
|
Target selection rectangle. See Common selection definitions. |
|
__u32 |
|
Flags. See v4l2-selection-flags. |
|
struct |
|
Selection rectangle, in pixels. |
|
__u32 |
|
Stream identifier. |
|
__u32 |
|
Reserved for future extensions. Applications and drivers must set the array to zero. |
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.
-
EBUSY
The selection rectangle can't be changed because the pad is currently busy. This can be caused, for instance, by an active video stream on the pad. The ioctl must not be retried without performing another action to fix the problem first. Only returned by
VIDIOC_SUBDEV_S_SELECTION -
EINVAL
The struct
v4l2_subdev_selectionpadreferences a non-existing pad, thewhichfield has an unsupported value, or the selection target is not supported on the given subdev pad. -
EPERM
The
VIDIOC_SUBDEV_S_SELECTIONioctl has been called on a read-only subdevice and thewhichfield is set toV4L2_SUBDEV_FORMAT_ACTIVE.
ioctl VIDIOC_SUBDEV_QUERYCAP
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBDEV_QUERYCAP - Query sub-device capabilities
Synopsis #
int ioctl(int fd, VIDIOC_SUBDEV_QUERYCAP, struct v4l2_subdev_capability *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_subdev_capability.
Description #
All V4L2 sub-devices support the VIDIOC_SUBDEV_QUERYCAP ioctl. It is used to identify kernel devices compatible with this specification and to obtain information about driver and hardware capabilities. The ioctl takes a pointer to a struct v4l2_subdev_capability which is filled by the driver. When the driver is not compatible with this specification the ioctl returns ENOTTY error code.
v4l2_subdev_capability
|
__u32 |
|
Version number of the driver. The version reported is provided by the V4L2 subsystem following the kernel numbering scheme. However, it may not always return the same version as the kernel if, for example, a stable or distribution-modified kernel uses the V4L2 stack from a newer kernel. The version number is formatted using the |
|
|
||
|
__u32 |
|
Sub-device capabilities of the opened device, see subdevice-capabilities. |
|
__u32 |
|
Reserved for future extensions. Set to 0 by the V4L2 core. |
|
V4L2_SUBDEV_CAP_RO_SUBDEV |
0x00000001 |
The sub-device device node is registered in read-only mode. Access to the sub-device ioctls that modify the device state is restricted. Refer to each individual subdevice ioctl documentation for a description of which restrictions apply to a read-only sub-device. |
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.
-
ENOTTY
The device node is not a V4L2 sub-device.
ioctl VIDIOC_SUBSCRIBE_EVENT, VIDIOC_UNSUBSCRIBE_EVENT
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
Name #
VIDIOC_SUBSCRIBE_EVENT - VIDIOC_UNSUBSCRIBE_EVENT - Subscribe or unsubscribe event
Synopsis #
int ioctl(int fd, VIDIOC_SUBSCRIBE_EVENT, struct v4l2_event_subscription *argp)
int ioctl(int fd, VIDIOC_UNSUBSCRIBE_EVENT, struct v4l2_event_subscription *argp)
Arguments #
-
fdFile descriptor returned by
open(). -
argpPointer to struct
v4l2_event_subscription.
Description #
Subscribe or unsubscribe V4L2 event. Subscribed events are dequeued by using the ioctl VIDIOC_DQEVENT ioctl.
v4l2_event_subscription
|
__u32 |
|
Type of the event, see event-type. |
|
__u32 |
|
ID of the event source. If there is no ID associated with the event source, then set this to 0. Whether or not an event needs an ID depends on the event type. |
|
__u32 |
|
Event flags, see event-flags. |
|
__u32 |
|
Reserved for future extensions. Drivers and applications must set the array to zero. |
|
|
0x0001 |
When this event is subscribed an initial event will be sent containing the current status. This only makes sense for events that are triggered by a status change such as |
|
|
0x0002 |
If set, then events directly caused by an ioctl will also be sent to the filehandle that called that ioctl. For example, changing a control using VIDIOC_S_CTRL will cause a V4L2_EVENT_CTRL to be sent back to that same filehandle. Normally such events are suppressed to prevent feedback loops where an application changes a control to a one value and then another, and then receives an event telling it that that control has changed to the first value. Since it can't tell whether that event was caused by another application or by the VIDIOC_S_CTRL call it is hard to decide whether to set the control to the value in the event, or ignore it. Think carefully when you set this flag so you won't get into situations like that. |
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.
YUV Formats
Peios Kernel / Userspace interfaces / System and device interfaces / Video4Linux
YUV is the format native to TV broadcast and composite video signals. It separates the brightness information (Y) from the color information (U and V or Cb and Cr). The color information consists of red and blue color difference signals, this way the green component can be reconstructed by subtracting from the brightness component. See Colorspaces for conversion examples. YUV was chosen because early television would only transmit brightness information. To add color in a way compatible with existing receivers a new signal carrier was added to transmit the color difference signals.
Subsampling #
YUV formats commonly encode images with a lower resolution for the chroma components than for the luma component. This compression technique, taking advantage of the human eye being more sensitive to luminance than color differences, is called chroma subsampling.
While many combinations of subsampling factors in the horizontal and vertical direction are possible, common factors are 1 (no subsampling), 2 and 4, with horizontal subsampling always larger than or equal to vertical subsampling. Common combinations are named as follows.
-
4:4:4: No subsampling -
4:2:2: Horizontal subsampling by 2, no vertical subsampling -
4:2:0: Horizontal subsampling by 2, vertical subsampling by 2 -
4:1:1: Horizontal subsampling by 4, no vertical subsampling -
4:1:0: Horizontal subsampling by 4, vertical subsampling by 4
Subsampling the chroma component effectively creates chroma values that can be located in different spatial locations:
-
The subsampled chroma value may be calculated by simply averaging the chroma value of two consecutive pixels. It effectively models the chroma of a pixel sited between the two original pixels. This is referred to as centered or interstitially sited chroma.
-
The other option is to subsample chroma values in a way that place them in the same spatial sites as the pixels. This may be performed by skipping every other chroma sample (creating aliasing artifacts), or with filters using an odd number of taps. This is referred to as co-sited chroma.
The following examples show different combination of chroma siting in a 4x4 image.
|
0 |
1 |
2 |
3 |
||||
|---|---|---|---|---|---|---|---|
|
0 |
Y |
C |
Y |
Y |
C |
Y |
|
|
1 |
Y |
C |
Y |
Y |
C |
Y |
|
|
2 |
Y |
C |
Y |
Y |
C |
Y |
|
|
3 |
Y |
C |
Y |
Y |
C |
Y |
|
0 |
1 |
2 |
3 |
||||
|---|---|---|---|---|---|---|---|
|
0 |
Y/C |
Y |
Y/C |
Y |
|||
|
1 |
Y/C |
Y |
Y/C |
Y |
|||
|
2 |
Y/C |
Y |
Y/C |
Y |
|||
|
3 |
Y/C |
Y |
Y/C |
Y |
|
0 |
1 |
2 |
3 |
||||
|---|---|---|---|---|---|---|---|
|
0 |
Y |
C |
Y |
Y |
C |
Y |
|
|
1 |
Y |
Y |
Y |
Y |
|||
|
2 |
Y |
C |
Y |
Y |
C |
Y |
|
|
3 |
Y |
Y |
Y |
Y |
|
0 |
1 |
2 |
3 |
||||
|---|---|---|---|---|---|---|---|
|
0 |
Y |
Y |
Y |
Y |
|||
|
1 |
Y |
Y |
Y |
Y |
|||
|
C |
|||||||
|
2 |
Y |
Y |
Y |
Y |
|||
|
3 |
Y |
Y |
Y |
Y |